È possibile raggiungerlo utilizzando la libreria SectionedRecyclerViewAdapter. Ha il concetto di "Sezioni" e ogni sezione può avere la propria intestazione.
Mi sembra che sia necessario raggruppare le chiamate per "data". Quindi è possibile creare la classe Sezione in questo modo:
class MySection extends StatelessSection {
String date;
List<Call> callList;
public MySection(String date, List<Call> callList) {
// call constructor with layout resources for this Section header, footer and items
super(R.layout.section_header, R.layout.section_footer, R.layout.section_item);
this.date = date;
this.callList = callList;
}
@Override
public int getContentItemsTotal() {
return callList.size(); // number of items of this section
}
@Override
public RecyclerView.ViewHolder getItemViewHolder(View view) {
// return a custom instance of ViewHolder for the items of this section
return new MyItemViewHolder(view);
}
@Override
public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {
MyItemViewHolder itemHolder = (MyItemViewHolder) holder;
// bind your view here
itemHolder.tvItem.setText(callList.get(position).getContactName());
}
@Override
public RecyclerView.ViewHolder getHeaderViewHolder(View view) {
return new SimpleHeaderViewHolder(view);
}
@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder holder) {
MyHeaderViewHolder headerHolder = (MyHeaderViewHolder) holder;
// bind your header view here
headerHolder.tvItem.setText(date);
}
}
Quindi impostare la RecyclerView con le Sezioni:
// Create an instance of SectionedRecyclerViewAdapter
SectionedRecyclerViewAdapter sectionAdapter = new SectionedRecyclerViewAdapter();
MySection mySection1 = new MySection("27 Mar, 2016", callList1);
MySection mySection2 = new MySection("28 Mar, 2016", callList2);
// Add your Sections
sectionAdapter.addSection(mySection1);
sectionAdapter.addSection(mySection2);
// Set up your RecyclerView with the SectionedRecyclerViewAdapter
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(sectionAdapter);
Grazie amico. Questa libreria ha funzionato – hunkhusain