Go to a item in Listview without using smoothScrollToPosition

android, list, listview, scroll, selection

Solution

Try this out:

    myListView.post(new Runnable() 
    {
        @Override
        public void run() 
        {
            myListView.setSelection(pos);
            View v = myListView.getChildAt(pos);
            if (v != null) 
            {
                v.requestFocus();
            }
        }
    });

From this Google Developer list answer by Romain Guy Link

Problem

I'd like to go to (display) a specific item in my listview but without scrolling. I don't want any animation but I'd like to be instantaneously transported to the desired item. I'm using a checkable listview : `mylistview.setChoiceMode(1)` . I understood that `mylistview.setSelection(position)` is the solution, but when I use it, nothing happens (maybe because it's a checkable listview ?). When I use `mylistview.smoothScrollToPosition(position)`, it works well but I have obviously this scroll animation which I don't want. What could I do ? Thanks.

Original source

Related problems