开发者

Android List view with separators

开发者 https://www.devze.com 2023-04-04 14:27 出处:网络
I want to create a listview with separators like in the default contacts application. My application needs that the list be sor开发者_StackOverflow社区ted and the items be separated by separators(like

I want to create a listview with separators like in the default contacts application. My application needs that the list be sor开发者_StackOverflow社区ted 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!!


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

https://github.com/emilsjolander/StickyListHeaders


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.


Try to look this open source project.

https://code.google.com/p/android-amazing-listview/


You can set the divider and their width via xml or code :

  • http://developer.android.com/reference/android/widget/ListView.html#attr_android:dividerHeight

  • http://developer.android.com/reference/android/widget/ListView.html#attr_android:divider

  • http://developer.android.com/reference/android/widget/ListView.html#setDivider(android.graphics.drawable.Drawable)

  • http://developer.android.com/reference/android/widget/ListView.html#setDividerHeight(int)

For using the default divider , use "?android:attr/listDivider" for the "divider" attribute.

Also, in order to be able to do the scrolling in a different, faster way, use fastScrollEnabled .

0

精彩评论

暂无评论...
验证码 换一张
取 消