Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I jump to an item of a list view in android?

I have an application where I have one edittext. And also I have one listview that is populated with 100 items and can show only 5 items at a time. I enter a number (n) in the Edittext and I want listview to jump to the n th item of the list view and that n th item should come at the top of the viewable area (the one that shows 5 listview items). Can you please tell me how this can be achieved..

like image 560
shashi Avatar asked Mar 07 '11 16:03

shashi


People also ask

What is a list view in android?

A list view is an adapter view that does not know the details, such as type and contents, of the views it contains. Instead list view requests views on demand from a ListAdapter as needed, such as to display new views as the user scrolls up or down. In order to display items in the list, call setAdapter(android.

Is ListView deprecated Android?

It's worth to mentioned that the ListView is a kind of deprecated because the RecyclerView was introduced with the API 21 (Android Lollipop).


1 Answers

A call to setSelection(position) should do the trick.

like image 97
Robby Pond Avatar answered Sep 18 '22 12:09

Robby Pond