Sandeep Chayapathi
Sandeep Chayapathi

Reputation: 1610

GridView with section headers

Im trying to implement a GridView with section headers. I found one other question here Android GridView with categories? , however following the accepted answer gives me "header" as cells instead of the header being in its own row.

Im not sure what Im missing here (have tried the MergeAdapter too), can someone point out the nuance thats needed to implement the section headers in a GridView ?

Upvotes: 3

Views: 10518

Answers (2)

korosmatick
korosmatick

Reputation: 579

Try modifying the usual listview adapter to return grid cells see here

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007379

This is not strictly possible. GridView does everything in terms of cells.

Now, you are welcome to create a set of cells that, when displayed together in a row, happen to look like a header. Presumably my MergeAdapter can handle that, though I have certainly never tried it. It will be up to you to ensure that:

  • the header cells are all in one row, which implies that...
  • empty cells go in any spaces in the preceding row, after the last "real" cell and before your header cells, and...
  • that you have the right number of header cells (i.e., equal to your number of columns), and...
  • that the header cells render correctly to look like a contiguous header, and...
  • that you use areAllItemsEnabled() and isEnabled() correctly, so that the header cells and the empty cells are not enabled

Upvotes: 6

Related Questions