Android : GridView setOnItemClickListener effects multiple items

on Monday, August 4, 2014


When I click the GridView item multiple checks appear where I just want it to appear in the one. I'm pretty sure this has something to do with the recycled views, but I am not sure how to prevent it from happening. Any advice is appreciated.



grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
final int position, long id) {
ImageView check = (ImageView) view.findViewById(R.id.check);
if (check.getVisibility() == View.GONE) {
check.setVisibility(View.VISIBLE);

I
}

else {
check.setVisibility(View.GONE);

}
}
});

0 comments:

Post a Comment