1

I want to make a listView ... just like this .. any suggestions ?

enter image description here

mnagy
  • 1,085
  • 1
  • 17
  • 36
  • 1
    duplicate 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 Answers2

0

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.

Swayam
  • 16,294
  • 14
  • 64
  • 102
0

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

BigBen3216
  • 868
  • 1
  • 8
  • 23