A user selects an answer from a series of options in a listview. After submitting (right or wrong) I intend to highlight the correct answer in the list view.
I thought I had it figured:
// get the position from the array we fed into the list view that has the correct answer
int correct = curquestion.GetIndexOfCorrectAnswer();
// set that item's background to yellow
lView.getChildAt(correct).setBackgroundColor(Color.YELLOW);
I’ve discovered though through watching this run, and reading other people’s posts herem that getChildAt doesn’t provide a reliable result- sometimes it appears to pick a random child to set yellow. Any suggestions on other approaches?
Enter position of list item at which you want to set color:
and in adapter class:
// change the row color based on selected state
Hope this helps.