Hey Got problem while selecting item in a ListView
, on each list item onClick()
i'm trying to enable button
. Button
I want to make choice mode single, even though implementing choice mode single in xml
. Its allowing me multiple selection of my ImageButton
. What i want to achieve over here is, only user can select one ListView
item at a time, but over here ImageButton
is staying clicked for multi selection of ListView
.
Can anyone help me on this issue please
public class LazyAdapter extends BaseAdapter{
private Activity activity;
private String[] data;
private String[] imageNames;
private String[] creatives;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public String assetId;
public LinearLayout creativeSaveChanges,cancelCreative;
public LazyAdapter(Activity a, String[] imageurl,String[] names,String[] creativeId) {
activity = a;
data=imageurl;
imageNames = names;
creatives = creativeId;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.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) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.boards_creative_custom_listview, null);
cancelCreative = (LinearLayout)vi. findViewById(R.id.cancelCreative);
creativeSaveChanges = (LinearLayout)vi. findViewById(R.id.creativeSaveChanges);
TextView text=(TextView)vi.findViewById(R.id.specialTxtFridaySpecialTroopsList);;
ImageView image=(ImageView)vi.findViewById(R.id.imageboardsCreativeList);
final ImageButton selectbutton = (ImageButton) vi.findViewById(R.id.imageButtonRefreshListCreative);
text.setText(imageNames[position]);
imageLoader.DisplayImage(data[position], image);
vi.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
selectbutton.setBackgroundResource(R.drawable.rightblue);
assetId = creatives[position];
Log.e("creatives", assetId);
for (int i = 0; i <creatives.length; i++) {
if(i == position){
Log.e("creatives.length", i+" ,"+position+"");
}else if(i != position){
selectbutton.setVisibility(View.GONE);
Log.e("creatives.length", i+" and "+position+"");
}
}
}
});
return vi;
}
}