I have a listview which displays several items. Now I want to scroll to some specific item (e.g. the 33th item). I know that this can be done via
myList.setSelection(32);
But on the UI the item doesn't receive any highlighting (because it is in touch mode?!). How can I apply a specific background color for this item? I tried
myList.getSelection().getSelectedView().setBackgroundColor(Color.Red);
but i get a NullPointerException because getSelectedView() returns null. Is there a way to achieve this highlighting? I have to notify the user somehow about which item is the "active" one...
I tried by the following way and solved the problem.
Created a javaBean class that receives the position. Like following.
Then from The
OnListItemClickListener()
I set the position of the selected item. Like followingThen in the adapter class do the following
Try this one to change the Selected row background color change in Android List view.