1

I am using ListView and have successfully populated it with the data of a database table using SimpleCursorAdapter .My question is how to add Column names of the database table, to the columns generated in the ListView.

AAg
  • 97
  • 1
  • 1
  • 7
  • Check this out mate, I had a similar problem at hand some days earlier: http://stackoverflow.com/questions/18532850/treemap-to-listview-in-android – Skynet Oct 12 '13 at 09:29

1 Answers1

2

You can include your ListView row layout at the top of your ListView Element in Xml.

<include layout="@layout/report_row"/>
<ListView
    android:id="@+id/YourList"
    android:layout_width = "match_parent"
    android:layout_height = "match_parent"
    >
    </ListView>

or you can add a HeaderView to your list which contains a ViewGroup of your List columns

YourList.addHeaderView(View, null, false);
Arash GM
  • 10,316
  • 6
  • 58
  • 76
  • 1
    Very IMPORTANT!: adding header view shifts your list items by 1, meaning that list[0] is now the header view, even though it is sticky. you can have a view separate from your list, and maintain it standalone – Lena Bru Oct 12 '13 at 22:40