I have a ListView populated by a string-array. I want to select an item dynamically but .setSelection(1) and .setSelectionFromTop(1,100) does not work.
list.setSelection(2);
Log.i(TAG, "my pos: "+ list.getSelectedItemPosition());
This traces out “my pos: -1”
Does anyone have any ideas?
setSelection()andgetSelectedItemPosition()refer to two different things.“Selection” refers to the first visible row, as in
getFirstVisiblePosition().“Selected” refers to a selected View, as in
View#setSelected().Which one do you want?