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..
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.
It's worth to mentioned that the ListView is a kind of deprecated because the RecyclerView was introduced with the API 21 (Android Lollipop).
A call to setSelection(position) should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With