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
In my case, when using simple_list_item_2, the only solution was to override the getView() method of the adapter, and just change the background color manually:
listview = new SimpleAdapter(ctx, data,
android.R.layout.simple_list_item_2, res,
new String[] {"field1", "field2" },
new int[] {android.R.id.text1, android.R.id.text2 })
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
if (this_is_the_selected_item)
{
view.setBackgroundColor(0xff999999);
}
else
{
view.setBackgroundColor(Color.BLACK);
}
return view;
}
};
Remember to call listview.invalidateViews() whenever you change the selected item.