可以展开、折叠分组,支持添加多种divider的adapter
compile 'com.wanjian:expandable-recyclerview:0.0.1'
支持多种group布局和多种child布局
继承NestedAdapter
,实现下列方法即可,跟使用ExpandableListview
类似
protected abstract int getGroupCount();
protected abstract int getChildCount(int groupIndex);
protected int getGroupItemViewType(int groupIndex) {
return 1;
}
protected int getChildItemViewType(int groupIndex, int childIndex) {
return 1;
}
protected abstract G onCreateGroupViewHolder(ViewGroup parent, int viewType);
protected abstract void onBindGroupViewHolder(G holder, int groupIndex);
protected abstract C onCreateChildViewHolder(ViewGroup parent, int viewType);
protected abstract void onBindChildViewHolder(C holder, int groupIndex, int childIndex);
支持添加头部,尾部,group间,child间,group和child间添加自定义divider
public NestedAdapterDivider setDividerBetweenGroup(Drawable dividerBetweenGroup)
public NestedAdapterDivider setDividerBetweenChild(Drawable dividerBetweenChild)
public NestedAdapterDivider setDividerBetweenGroupAndChild(Drawable dividerBetweenGroupAndChild)
public NestedAdapterDivider setDividerBeforeFirstGroup(Drawable dividerBeforeFirstGroup)
public NestedAdapterDivider setDividerAfterLastGroup(Drawable dividerAfterLastGroup)
继承自ExpandableAdapter即可,调用如下方法实现展开折叠,同样支持多种group布局和多种child布局
public void collapseGroup(int groupIndex)
public void expandGroup(int groupIndex)
public boolean isExpand(int groupIndex)
public void collapseAllGroup()
相关方法如下
public void notifyGroupItemChanged(int groupIndex)
public void notifyGroupChanged(int groupIndex)
public final void notifyChildItemChanged(int groupIndex, int childIndex)
public final void notifyChildItemRangeChanged(int groupIndex, int childIndex, int itemCount)
public final void notifyChildItemInserted(int groupIndex, int childIndex)
public final void notifyChildItemRangeInserted(int groupIndex, int childIndex, int itemCount)
public final void notifyChildItemRemoved(int groupIndex, int childIndex)
public final void notifyChildItemRangeRemoved(int groupIndex, int childIndex, int itemCount)