Если бы мне понадобился разделитель между разделами, я бы попытался определить тип для заголовков разделов в глобальном классе адаптеров recyclerview:
private static final int TYPE_SMS_MESSAGE = 0;
private static final int TYPE_PHONE_CALL = 1;
private static final int TYPE_SECTION_HEADER = 2;
Затем я бы вернул макет с TextView и разделительной линией под ним..
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
case TYPE_SMS_MESSAGE:
// return a view as you did before
case TYPE_PHONE_CALL:
// return a view as you did before
case TYPE_SECTION_HEADER:
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.section_header_layout, null);
return new YourRecyclerViewHolder(v);
default:
return null;
}
}
Чтобы иметь возможность обнаруживать и возвращать этот макет, вам необходимо обнаружить, что он является экземпляром SectionHeader.
@Override
public int getItemViewType(int position) {
if (itemList.get(position) instanceof SectionHeader) {
return TYPE_SECTION_HEADER;
}
/* return TYPE_SECTION_HEADER if the data in the list is an instance of
SectionHeader and other corresponding types as well */
}
Надеюсь, это поможет вам понять идобиться прогресса в этом!Счастливое кодирование:)
Baki