I\'m trying to change the row color of my listView in customAdapter. There\'s an array of integer that include 0 and 1, I\'m trying to read from the array and change the color o
getView()
is called for each row in a list so you should not loop over all items in test
but only handle the one denoted by position
and you should do that after (not in) the if (convertView == null)
block.
Edit:
getView()
should do the following things:
Now we have a valid View for the list row.
test.get(position)
. The position
is the number of the requested row (starting with 0 at the top of the ListView).position
).In more complex situations you may have to do the third step before the second but not here.