How to generate a ListView with headers above some sections?

前端 未结 4 805
清歌不尽
清歌不尽 2020-12-03 12:55

I want to generate a ListView that has some dividers between some of the entries, like it can be seen in some of the property sections. See the example below. I

4条回答
  •  旧巷少年郎
    2020-12-03 13:23

    I'm also interested in an answer to this. There must be a more straightforward way to do this.

    In looking at the Adapter, there's a method, Adapter.getItemViewType(int position).

    ListView defines a return value, ITEM_VIEW_TYPE_HEADER_OR_FOOTER which indicates if the returned item is a header or footer.

    I haven't tried it, but I assume if you create your own Adapter and return an item with the type indicating it is a header or footer, that the ListView will display it appropriately.

提交回复
热议问题