Android : How to populate a ListView with alphabet indexer and fastscroll as in contacts app.?
Asked Answered
Y

3

7

I would like to implement a ListView with fastscroll and albhabet indexer as in the contacts application. I'm using a SimpleAdapter to populate the ListView. As seen from the image, by selecting a letter from the alphabet indexer at the right, the listView selection goes to the corresponding ListItem. How to accomplish this? Please help.

enter image description here

Yamauchi answered 7/12, 2011 at 11:35 Comment(1)
R
5

As I can't see your posted image, but I think

Here is the way to implement Section Indexing in Android as iPhone has, You should also refer Sectionindexer & alphabetindexer for such custom implementation.

  1. https://github.com/emilsjolander/StickyListHeaders
  2. https://github.com/JimiSmith/PinnedHeaderListView
  3. http://hello-android.blogspot.com/2010/11/sideindex-for-android.html

Try this, Hope this what you need..

Reduced answered 7/12, 2011 at 12:57 Comment(1)
Thank you for your response. I'm sorry to say that the I am unable to download the tutorial from first link. The page doesn't get displayed do to some issue. And the second link, I have already tried to customize it. But it still doesn't serve my purpose. Anyway, thank you for your answer. Please do update if you find any other interesting solution.Yamauchi
P
3

I know that this is late, Still here is a my github repo with an android project with list section header and alphabet indexer. I also implemented filter in it. Hope it helps someone.

enter image description here

Poleyn answered 7/3, 2014 at 14:12 Comment(1)
Can you add the relevant bits of code to your post?Tophet
E
0

I will let you know in brief.

Create a class extends RelativeLayout implements OnTouchListener

Define a strings of alphabets

Find the screen height of list view

Create dyanamic textviews count same as number of alphabets, height of textView ==> screenWidth / alphabets.

Override onTouch method .

Find the textview which is currently selected//Offset.

Create a handler for sending the event to mainList

Call Listview setSelectionFromTop method pass the position.

Its done...

Eric answered 15/11, 2012 at 15:19 Comment(1)
It is better to use AlphabetIndexer with ListAdapterMandal

© 2022 - 2024 — McMap. All rights reserved.