Add two sections in recyclerview android

后端 未结 6 1094
天命终不由人
天命终不由人 2020-12-04 12:12

In my application i am using recyclerview to display all contact list. I want two section in recyclerview.

Like one section is my application contact list and second

6条回答
  •  不知归路
    2020-12-04 12:49

    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.

提交回复
热议问题