I am working on an android application. I have created a listview by using
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,arrayname));
getListView().setTextFilterEnabled(true);
Now i want to change the selected item's color. I could change the background of the selected item by placing
listviewobject.getChildAt(position).setBackgroundColor(Color.BLACK);
in onListItemClick()
this code is changing the background color but if I select any other list item then also the previously clicked list item's color is red.So I change the previously clicked listitem's color by
l.getChildAt(prevpos).setBackgroundColor(Color.BLACK);
now the problem is if i change the background of previously clicked listitems color to black.Then i can't see the text on that particular listitem.I i click again then only i can see the text on that item.So its look weired.please help me friends
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…