1
갤러리를 사용하여 일부 이미지를 표시하고 있습니다. 갤러리 아이템 선택을 위해 아래의 adpater와 gallery selector를 사용했습니다.갤러리 선택한 항목 backgound가 지속되지 않음
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