Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android - index for ListView?

Is it possible to have an index on the righthand side of a ListView? This is possible on the iPhone where running down the righthand side the alphabet is shown. Touching a letter on the alphabet brings one to the beginning of the items in the ListView that start with that letter.

Is there built-in code in Android for this functionality? Or is this something one would have to custom make?

like image 961
James Testa Avatar asked Aug 23 '10 16:08

James Testa


People also ask

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

What is the difference between RecyclerView and ListView in android?

Simple answer: You should use RecyclerView in a situation where you want to show a lot of items, and the number of them is dynamic. ListView should only be used when the number of items is always the same and is limited to the screen size.

How fetch data from sqlite database and show in ListView?

xml. Create an another layout file (list_row. xml) in /res/layout folder to show the data in listview, for that right click on layout folder à add new Layout resource file à Give name as list_row.


2 Answers

There is no exactly what you want. There is a very similar thing. First set fast scroll mode of your ListView:

ListView.setFastScrollEnabled(true);

next implement the following Interface by your adapter:

android.widget.SectionIndexer

http://developer.android.com/reference/android/widget/SectionIndexer.html

This way you will be able to scroll fast your ListView with a thumb button.

If you implement SectionIndexer correctly you will be able to see a alphabet letter on which you are currently on during fast scrolling.

like image 79
plugmind Avatar answered Sep 30 '22 14:09

plugmind


Check this one http://hello-android.blogspot.com/2010/11/sideindex-for-android.html .. exactly the same..

like image 26
xydev Avatar answered Sep 30 '22 14:09

xydev