I have i listview with 24 text views in it(each one of them present one hour of the day). What i am trying to do is to change background color of the item that i clicked.
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int i, long l) {
View v;
v = parent.getChildAt(i);
v.setBackgroundColor(Color.GREEN);
}
});
The problem is that when i click on a specific item not only bg color of one item is changed but also some other items change their colors.
i Know that
getChildAt()
does not always get the sam fixed item. I want to know how that should be done so that only the item that is clicked change bg color.
0 comments:
Post a Comment