How to create an alphabetical scrollbar displaying all the letter in android?
Solution 1:
This is an iPhone feature, Android uses fast scroll. I'd recommend that you use the platform alternative rather than try to enforce common functionality.
If you must, you'll have to implement this yourself. Put your list view in a RelativeLayout and put A-Z TextViews in a vertical LinearLayout that is set to layout_alignParentRight="true"
. Set the TextView's tag to A-Z appropiately and set onClick="quickScroll"
on all of them.
Implement in your Activity:
public void quickScroll(View v) {
String alphabet = (String)v.getTag();
//find the index of the separator row view
list.setSelectionFromTop(index, 0);
}
This will scroll to the selected letter onClick, but I believe you can scroll your finger over the alphabet on iPhone and it'll update the list? You'll have to implement an onTouchListener rather than onClickListener for that.
Solution 2:
You can try using IndexScroller
which only visible on touch and auto invisible when no contact.
Here is the screenshot