I have a list of albums (several hundred). When I touch the selected album I want to offer the user a choice of playing the whole album, or moving to its track ListView. No
I solved this by extending the ListView and overriding the getView() method. I kept an internal identifier for the "selected" state and changed the background of the item according to it, like this:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View currView = super.getView(position, convertView, parent);
StateListItem currItem = getItem(position);
if (currItem.isItemSelected) {
currView.setBackgroundColor(Color.RED);
} else {
currView.setBackgroundColor(Color.BLACK);
}
return currView;
}
I have an example program on my blog post: http://udinic.wordpress.com/2011/07/01/selectablelistview-make-selection-work/