GithubHelp home page GithubHelp logo

wareyang / expandable-recyclerview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from android-notes/expandable-recyclerview

0.0 1.0 0.0 2.84 MB

可以展开、折叠分组,支持添加多种divider的adapter

License: MIT License

Java 100.00%

expandable-recyclerview's Introduction

expandable-recyclerview

可以展开、折叠分组,支持添加多种divider的adapter

compile 'com.wanjian:expandable-recyclerview:0.0.1'

分组RecyclerView

支持多种group布局和多种child布局

group

继承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);

为NestedAdapter添加divider

divider

支持添加头部,尾部,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)  

展开折叠Recyclerview

group

继承自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) 

expandable-recyclerview's People

Contributors

android-notes avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.