views:

1087

answers:

1

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.

+2  A: 

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!

alex