我正在使用MergeAdapter(又称ConcatAdapter)进行编程。
https://medium.com/androiddevelopers/merge-adapters-sequentially-with-mergeadapter-294d2942127a
但我需要做的是第一个适配器显示网格布局,第二个适配器显示线性布局,因此,如果我这样做
val headerAdapter = HeaderAdapter(requireContext(), Header("TestHeader"))
val dividerViewAdapter = DividerViewAdapter(requireContext())
val animalAdapter = DividerViewAdapter(requireContext(),DataSource.animalList) // -> this should be shown as a GridLayout
val mergeAdapter = MergeAdapter(headerAdapter,dividerViewAdapter,animalAdapter)
test_rv.layoutManager = LinearLayoutManager(requireContext())
test_rv.adapter = mergeAdapter
现在这段代码可以正常工作,但由于它有一个LinearLayoutManager,所有内容都将显示为LinearLayout,其中我的animalAdapter将无法按照我想要的方式显示。
是否有任何方法为不同的适配器设置不同的layoutmanager,以便以我想要的方式显示数据?