If you want to have individual backgrounds for each item in the list, you must declare your own custom adapter.
Derive it from the BaseAdapter, and the most important part for the implementation is the getView(int, View, ViewGroup) method getView(int, View, ViewGroup) .
You need to understand how android reuses existing elements of the list item view when scrolling through the list. This means: at any given time, as many views will be displayed as can be seen on the screen at the same time.
This optimal strategy of not generating too many views in general leads to the problem that you will need to set the background for each list item according to their position, which is necessary when getView is called. If you try to set the background statically only when creating the view, it will reappear again, possibly tied to the wrong item.
The getView method either brings "convertView" as the second parameter or not (null). If your method is called with the set convertView value, it means: "reuse this view for the element that is required right now."
The technique used here is well described in the API demos (Lists sections), as well as for this video blog.
Here's how to do it:
public class MyAdapter extends BaseAdapter { public View getView(int position, View convertView, ViewGroup parent) {
This is basically it. If there are only a few background images, I would probably cache them, so you don't need to read the resources again and again!
Good luck
source share