Okay so I've been able to hightlight an item in a ListView, but it ends up highlighting every fourth item. I'm pretty sure that's because of recycling. Then I had the issue where the highlighted item would go back to normal after I scrolled, and that's also because of recycling. Is there any way to keep it highlighted, or to maybe stop the ListView from recycling?
This is what the code looks like right now...
runTimes.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> list, View v, int pos, long id) {
v.setSelected(true);
}
});
This is the code where the highlighted item goes back to normal after you scroll.
If you want to stop
ListView
from recycling you should think again if you really need aListView
.To properly accomplish this with a
ListView
, though, you need to save the highlighted item states inside of your adapter. Then ingetView
highlight the items based on their position.There have been A LOT of questions about saving the state of the
ListView
items, I'm sure you can find some.