How to implement RecyclerView with section header depending on category?

前端 未结 4 1791
傲寒
傲寒 2020-12-25 15:12

I want to implement sections in my list. I have a list of tasks. List has a custom adapter which extends recyclerview swipe adapter as I have implemented swipe gesture to th

4条回答
  •  抹茶落季
    2020-12-25 15:46

    Take a look at my library on Github, can be used to easily create sections: RecyclerAdapter & Easy Section

    mRecylerView.setLayoutManager(...);
    /*create Adapter*/
    RecyclerAdapter baseAdapter = new RecyclerAdapter<>(...);
    /*create sectioned adapter. the Adapter type can be RecyclerView.Adapter*/
    SectionedAdapter adapter = new SectionedAdapter<>(SectionViewHolder.class, baseAdapter);
    /*add your sections*/
    sectionAdapter.addSection(0/*position*/, "Title Section 1");
    /*attach Adapter to RecyclerView*/
    mRecylerView.setAdapter(sectionAdapter);
    

    Hope it helps.

提交回复
热议问题