yotam2010
Newbie
I try to change the color of list item on long click. for some reason it color the item and every 4th item.
(color the item i pressed and every 4th item which is out side the screen when i scroll to it)
the code:
the resault is something like:
View
View
View
View
View
View
View
(color the item i pressed and every 4th item which is out side the screen when i scroll to it)
the code:
Java:
mQuestionListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
TextView textView = (TextView)view.findViewById(R.id.list_item_Question);
if(!mListItemPicked.contains(position)) {
mMenu.findItem(R.id.delete_Question_menu_item).setVisible(true);
mMenu.findItem(R.id.edit_Question_menu_item).setVisible(true);
textView.setBackgroundColor(Color.RED);
mListItemPicked.add(position);
}else{
textView.setBackgroundColor(Color.WHITE);
mListItemPicked.remove(mListItemPicked.indexOf(position));
if(mListItemPicked.size()==0){
mMenu.findItem(R.id.delete_Question_menu_item).setVisible(false);
mMenu.findItem(R.id.edit_Question_menu_item).setVisible(false);
}
}
return false;
}
});
the resault is something like:
View
View
View
View
View
View
View