How do I set the background color or image of a cell in a ListView (or ListActivity) on Android?
This is a very simple ListView with just a few items in it and no other customization. I don’t want to change the text or text color or size or anything like that, I just want to change the color or background image of the cells in the ListView.
What is the simplest way to do this in code (not layout XML)?
Here is the code I am using in my ListActivity:
listitems.add("1");
listitems.add("2");
listitems.add("3");
this.getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
setListAdapter(new ArrayAdapter<String>(
this,
android.R.layout.simple_list_item_checked,
listitems
));
Thanks to newbyca for leading me in the right direction. This is what I was looking for and is actually the best answer as it’s the easiest code to implement: