在RecyclerView的下一部分组的开头添加标题或文本

时间:2018-09-02 18:11:08

标签: android android-recyclerview kotlin

我想添加一个节标题或某些内容来声明其新节,但是我做对了。我注释掉的testSection.setHeader()方法需要一个名为Header : Group的项目。

这是“回收者”视图的代码:

private fun updateRecyclerViewTest(items: List<Item>) {
    fun init() {
        recycler_view_test.apply {
            layoutManager = LinearLayoutManager(this@EditModActivity)
            adapter = GroupAdapter<ViewHolder>().apply {
                testSection = Section(items)
                assSection = Section(items)
                //pracSection = Section(items)
                add(testSection)
                add(assSection)
                //add(pracSection)
                setOnItemClickListener(onItemClick)
            }
        }
        shouldInitRecyclerView = false
    }
    if (shouldInitRecyclerView)
        init()
    else
    {

        testSection.update(items.subList(0,3))
        //testSection.setHeader()
        assSection.update(items.subList(4,6))
        //pracSection.update(items.subList(6,9))
    }
}

这是当前输出

output

0 个答案:

没有答案