I’m trying to paint some single rows in a listview but I don’t know how to do it. I only know how to change the background of the whole listview. My current code is this:
public void paintBackgroundRed(ArrayList<Integer> profileIngList, ArrayList<Integer> productIngList){
ListView lv = (ListView) findViewById(R.id.list_ingredients);
for(int profileIng: profileIngList)
{
if (productIngList.contains(profileIng)){
// paint int profileIng red
}
}
}
I have an hashmap so I can map the row to the profile ingredient ID. How can I paint the row that is commented? Thanks.
You should be doing the color changing in your adapter. When you prepare the view (in getView), you can decide which color the background should be for the given element.