Move to item in Listview without using smoothScrollToPosition
I would like to (show) a specific item in my list, but without scrolling. I don't need animation, but I would like to be instantly delivered to the desired element.
I'm using checked the listview control: mylistview.setChoiceMode(1)
.
I figured out what mylistview.setSelection(position)
is the solution, but when I use it nothing happens (maybe because this is a checked listview?).
When I use mylistview.smoothScrollToPosition(position)
it works well, but I clearly have this scroll animation I don't want.
What can I do?
Thank.
+2
Jecimi
source
to share
1 answer
Try the following:
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 by Romain Guy Link
+8
antew
source
to share