I have a ListActivity
that implements onListItemClick()
and calls a doSomething()
function of the class. The latter contains l.s
For me it helped to set
ListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
or ListView.CHOICE_MODE_MULTIPLE
then
ListView.setSelection(position)
or ListView.setItemChecked(position, true);
works fine
use requestFocusFromTouch()
before calling setSelection()
method
maybe you need to use function:
ListView.setItemChecked(int position, boolean checked);
Simply try this code
listView.setAdapter(adapter);
listView.setSelection(position);
adapter.notifyDataSetChanged();
setSelection()
does not necessarily have visual impact. The selection bar only appears if you use the D-pad/trackball to navigate the list. If you tap on the screen to click something, the selection bar appears briefly and vanishes.
Hence, setSelection()
will only have a visual impact if the activity is not in touch mode (i.e., the last thing the user did was use the D-pad/trackball).
I am not 100% certain this explains your phenomenon given the description you provided, but I figured it is worth a shot...