Я пытаюсь создать список изображений, в котором я могу выбрать несколько элементов, у меня есть один значок да, который я хочу установить видимым для любых выбранных элементов (, например, флажок ) и невидимым при отмене выбора. .. Я добавил изображение в XML-файл и установил его visibility as GONE
(так как оно не должно быть видно изначально) .. Пожалуйста, скажите мне возможные решения ..
для списка, который я установил list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
И мой пользовательский BaseAdapter
класс содержит,
public static class ViewHolder{
public TextView text;
public ImageView image,yesimage;
public TextView quantity;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
final ViewHolder holder;
if(convertView==null){
vi = inflater.inflate(R.layout.item, null);
holder=new ViewHolder();
holder.image=(ImageView)vi.findViewById(R.id.image);
holder.text=(TextView)vi.findViewById(R.id.text);
holder.quantity=(TextView)vi.findViewById(R.id.quantity);
holder.yesimage=(ImageView)vi.findViewById(R.id.selectedyes);
vi.setTag(holder);
}
else
holder=(ViewHolder)vi.getTag();
// Here I wanted to know how can i set visibility of yesimege for individual selected items on list
holder.text.setText(items[position]);
holder.image.setTag(data[position]);
holder.quantity.setText(Integer.toString(qty[position]).trim());
imageLoader.DisplayImage(data[position], activity, holder.image);
return vi;
}
фрагмент xml item.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="50dip"
android:layout_height="50dip"
android:src="@drawable/stub"
android:scaleType="centerCrop"/>
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="left|center_vertical"
android:textSize="15dip"
android:typeface="sans"
android:textColor="#000000"
android:layout_marginLeft="10dip"/>
<TextView
android:id="@+id/quantity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="right|center_vertical"
android:gravity="right"
android:paddingRight="10dp"
android:textSize="18dip"
android:typeface="sans"
android:textColor="#000000"/>
<ImageView android:id="@+id/selectedyes"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="gone"
android:src="@drawable/itemselected"
android:layout_marginRight="8dip"
android:soundEffectsEnabled="false" ></ImageView>
</LinearLayout>