Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
E

ExpandableRecyclerView

> 编程语言
Open source

Customized recyclerViewAdapter which shows items in a 2-level list.

370 stars0 likes0 views
WebsiteGitHub

About

Customized recyclerViewAdapter which shows items in a 2-level list.

ExpandableRecyclerView

【中文README】

Customized recyclerViewAdapter which shows items in a 2-level list.

It encapsulates the expand and fold operation in abstract class BaseExpandableListAdapter,which makes it flexible.

See the usage below , all you need to do is just extending the class and overriding these 6 methods:

  • getGroupCount
  • getGroupItem
  • onCreateGroupViewHolder
  • onCreateChildViewHolder
  • onBindGroupViewHolder
  • onBindChildViewHolder

As onCreateViewHolder & onBindViewHolder are compulsive methods which need developers to override. All your extra work is overriding getGroupCount & getGroupPosition. In most conditions , it is just a one-line-method.

Gradle

groovy
dependencies{
	compile 'com.hgDendi:expandable-recyclerview-adapter:1.0.1'
}

Usage

…

Relating classes:

…

ShowEmptyView

Show empty view when list is empty.

java
adapter.setEmptyViewProducer(new ViewProducer() {
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent) {
        View emptyView = LayoutInflater.from(parent.getContext()).inflate(R.layout.empty, parent, false);
        return new DefaultEmptyViewHolder(emptyView);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder) {
    }
});

VariousGroup&Child

Override getGroupType & getChildType.

Override onCreateViewHolder to generate different ViewHolder.(The same as original RecyclerViewAdapter)

java
protected int getGroupType(GroupBean groupBean) {
    return 0;
}

abstract public GroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int groupViewType);
    
protected int getChildType(GroupBean groupBean, ChildBean childBean) {
    return 0;
}

abstract public ChildViewHolder onCreateChildViewHolder(ViewGroup parent, int childViewType);

AddHeaderView

java
adapter.setEmptyViewProducer(new ViewProducer() {
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent) {
        View emptyView = LayoutInflater.from(parent.getContext()).inflate(R.layout.header, parent, false);
        return new DefaultEmptyViewHolder(emptyView);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder) {
    }
},false);

License

MIT

https://rem.mit-license.org/

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Java

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言