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));

10 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
  3. Michal

    How to read the coordinates of the touch (in the touch event)
    send the correct position in the performItemClick command?

    I would also like to handle touches in an empty space on the list.

    Reply

Leave a Reply to Parth Cancel reply

Your email address will not be published.