Android ListView with different layouts for each row

前端 未结 6 1664
独厮守ぢ
独厮守ぢ 2020-11-21 07:09

I am trying to determine the best way to have a single ListView that contains different layouts for each row. I know how to create a custom row + custom array adapter to sup

6条回答
  •  南旧
    南旧 (楼主)
    2020-11-21 07:51

    ListView was intended for simple use cases like the same static view for all row items.
    Since you have to create ViewHolders and make significant use of getItemViewType(), and dynamically show different row item layout xml's, you should try doing that using the RecyclerView, which is available in Android API 22. It offers better support and structure for multiple view types.

    Check out this tutorial on how to use the RecyclerView to do what you are looking for.

提交回复
热议问题