Android : How to programmatically click / select / tap a listview item

When its not in some sort of mode where it is touchable?
and all of this doesn’t work

3 is the index of the item you would like to click

listView1.performItemClick(listView1, 3, listView1.getItemIdAtPosition(3));

7 thoughts on “Android : How to programmatically click / select / tap a listview item

  1. David B.

    I tried this and it works at the most cases, the only strange case that I could not figure out yet why it happens, is when you rotate the device then I call a performClick to say Position cero, the onClickListener is called and the DetailView for the positioned cero is called, BUT if the last activated item was positioned 3, positioned 3 still continues highlighted.

    Reply
  2. Porroe

    I think this should be:

    listView1.performItemClick(listView1getChildAt(3), 3, listView1.getItemIdAtPosition(3));

    So you send just the row you need and not the whole listview.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *