I want to make a listView ... just like this .. any suggestions ?
-
1duplicate of [Android ListView Headers](http://stackoverflow.com/questions/1966802/android-listview-headers) and http://stackoverflow.com/questions/13590627/android-listview-headers and many other SO questions. A trivial search for `android listview headers` also turns up open source components like http://code.google.com/p/android-amazing-listview/, blog posts like http://kmansoft.com/2010/11/16/adding-group-headers-to-listview/, and so on. – CommonsWare Feb 22 '13 at 21:34
2 Answers
Are you sure that you want to use a ListView
..?
In case the elements are totally different, you cannot have a common layout for each row, i.e. the child elements. You can obviously use ListView Headers
to achieve this and use getView()
to determine whether to show the checkbox or not..
However, the easy (and probably unethical way) would be to simply use a LinearLayout
inside a ScrollView
, if you have too many elements to be displayed, assuming you have a fixed number of elements to be displayed which is known beforehand.
But, the best thing to do in your case would be to use a PreferenceActivity
. It is the commonly used Activity for the Settings screen and is optimised for that purpose only, like user preferences in the settings screen of any application.
EDIT : As you mentioned in the comments that you only wish to display list of items in categories and not the checkboxes, I am assuming that you are not designing a Settings screen. In that matter, it would be relevant for you to use an ExpandableListView
, where you can display the list of categories as parents and the items under each category as the children.
Or, as @CommonsWare sir already suggested in the comments to your question, use headers for ListView to display the categories.

- 16,294
- 14
- 64
- 102
-
I just one to make similar one .. with all rows are the same .. containing images and at text .. but with categories .. not checkboxes or other things – mnagy Feb 22 '13 at 21:42
-
-
If you want to get something just like the picture you posted you could try a preference activity: http://developer.android.com/reference/android/preference/PreferenceActivity.html

- 868
- 1
- 8
- 23