Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating categories in a ListView?

How do I create categories in an arbitrary ListView like those in Preferences (PreferenceCategory)?

I've found android.R.layout.preference_category that renders that grey TextView but don't see it mentioned anywhere from java code.

like image 744
yanchenko Avatar asked Jun 18 '09 16:06

yanchenko


1 Answers

How do I create categories in an arbitrary ListView like those in Preferences (PreferenceCategory)? I've found android.R.layout.preference_category that renders that grey TextView but don't see it mentioned anywhere from java code.

http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/

Note that the code is from Android 0.9 and may require minor modifications to work in Android 1.5.

I have an Android 1.5-compatible variant on his code up at:

http://commonsware.com/AdvAndroid/

(scroll down, click on the Source Code link, and look at the ListView/Sections project)

-- Mark Murphy (a Commons Guy) http://commonsware.com The Busy Coder's Guide to Android Development Version 2.0 Available!

Thanks, Mark!

like image 135
yanchenko Avatar answered Oct 30 '22 18:10

yanchenko