public ImageAdapter(Context c) {
mContext = c;
TypedArray a = obtainStyledAttributes(R.styleable.Gallery);
mGalleryItemBackground = a.getResourceId(
R.styleable.Gallery_android_galleryItemBackground, 0);
a.recycle();
}
R.styleable.Gallery_android_galleryItemBackground, 0); 不是设置背景吗?,这句代码中的0是什么意思呢?
是返回的一个默认值。
可用这样理解---如果R.styleable.Gallery_android_galleryItemBackground没有定义或者不是一个资源的时候,就会返回0(默认值),比如你想在资源文件中获取长度,但是这个资源定义错误了,那么你得到的长度将为0。
你可以在返回值>0的时候进行你相关的操作。