I have a simple ListView with some elements for which setChoiceMode set to ListView.CHOICE_MODE_SINGLE , which means that when I touch an element, it is highlighted. Thus, the user can see which menu choice ( ListView is a menu):
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
However, I want to change this selection from the code (without touching). I tried this:
listView.setSelection(0);
but it does not seem to have any effect. Probably because selection and activation are different concepts. There is no setActivated(int) method available.
android listview
Bart friederichs
source share