Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android List view with separators

Tags:

android

I want to create a listview with separators like in the default contacts application. My application needs that the list be sorted and the items be separated by separators(like the alphabetical sorting in contacts application). Being able to scroll using the separator titles would be an added advantage. Any pointers would be helpful. Thanks!!

like image 928
Amol Gupta Avatar asked Sep 11 '11 07:09

Amol Gupta


People also ask

How to hide divider in ListView in Android?

To remove the separator using XML property you must simply add android:divider="@null" property to the ListView View that you have defined in the layout file.

How to change ListView line color in Android?

By default ListView separator line color is like light black but app developer can modify the listview separator line color using android:divider=” “ attribute in listview widget inside activity_main. xml layout file.


2 Answers

Take a look at this open source project, it gives you headers and they are sticky too:

https://github.com/emilsjolander/StickyListHeaders

like image 198
satur9nine Avatar answered Oct 19 '22 03:10

satur9nine


Go to your android-sdk\samples folder. There's a lot of examples with source. Try api demos -> Views -> Lists. This samples are everything you need and even more. Moreover HERE are official examples in Lists section.

like image 35
Y.A.P. Avatar answered Oct 19 '22 05:10

Y.A.P.