1
我正在使用圖庫來顯示一些圖像。我已經使用下面的adpater和gallery選擇器來進行圖庫項目選擇。圖庫選擇的項目背景不存在
ImageAdapter:
public class AddImgAdp extends BaseAdapter {
private int[] galleryImages;
public AddImgAdp(int[] images) {
galleryImages = images;
}
public int getCount() {
return galleryImages.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View convertView,
ViewGroup parent) {
final ImageView iv = new ImageView(ChooseLinerActivity.this);
iv.setImageResource(galleryImages[position]);
iv.setScaleType(ImageView.ScaleType.FIT_XY);
iv.setLayoutParams(new Gallery.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
iv.setBackgroundDrawable(getResources().getDrawable(
R.drawable.galleryselector));
iv.setAdjustViewBounds(true);
return iv;
}
}
galleryselector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:drawable="@drawable/large_button_sel2"/>
<item android:drawable="@android:color/transparent" />
</selector>
我的問題是,當我點擊或通過畫廊滾動它顯示的背景,但是當我點擊另一種觀點認爲這是在畫廊視圖,則該選擇消失。
你有沒有得到你的問題的答案。 – Prateek 2013-01-24 10:34:09