Skip to content Skip to sidebar Skip to footer

Set Activated Item In Listview Programmatically

I have a simple ListView with some items that have setChoiceMode set to ListView.CHOICE_MODE_SINGLE, which means when I touch an item, it is highlighted. This way the user can see

Solution 1:

you can select item with following code:

listView.setItemChecked(position, true);

Solution 2:

Using this method worked for me

listView.performItemClick(listView, position, listView.getItemIdAtPosition(position));

Solution 3:

The documentation says If in touch mode, the item will not be selected but it will still be positioned appropriately.

So, you need to use ListView.setItemChecked(int position, boolean checked) method as listView.setItemChecked(position, true) to set the position as selected

Post a Comment for "Set Activated Item In Listview Programmatically"