Reputation: 63
I made a listView, now is there a simple way to add hearders in it ? For example, make something like this
List.add("a")
list.addheader("Number")
list.add("1")
.
.
Widget_List_Adapter adapter = new Widget_List_Adapter(this, list);
.
.
.
setListAdapter(adapter);
Upvotes: 0
Views: 3595
Reputation: 1356
There's no section List(Table) View in Android, you can just add one top header, but if you want to make something like sectioned table view like IOS, here are some better resources.
android-section-list Just use this library it is awesome.
android-amazing-listview This one is also very user, even it allows you to load more functionality like FB.
How ever you can also make your own custom list, here is the complete blog.
Upvotes: 0
Reputation: 867
you could define a layout with a header layout followed by the listview. in the header layout you can define a textview that you can change in your code
Upvotes: 1
Reputation: 8528
The addHeaderView()
option only works to add a static header at the top of your list. If you want to add section headers, you'll have to do a considerable amount of extra work. This question should lead you down the proper path to make that happen.
Upvotes: 0
Reputation: 86948
Try using ListView#addHeaderView()
.
As a warning, you must call this method before calling setAdapter()
or setListAdapter()
, just like your pseudo-code example.
Upvotes: 6