Skip to content
RecyclerView implementation of traex's ExpandableLayout
Branch: master
Clone or download
Latest commit 392bc4c Jan 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
art
buildSrc Add badges Jan 16, 2019
demo
gradle/wrapper AndroidX migration Jan 16, 2019
recyclerview-expandable AndroidX migration Jan 16, 2019
.gitignore
.travis.yml Gradle 5.1-rc-3 Dec 29, 2018
LICENSE 0.4.0 Jun 27, 2017
README.md
build.gradle.kts
gradle.properties Gradle 5.1-rc-3 Dec 29, 2018
gradlew
gradlew.bat
settings.gradle.kts AndroidX migration Jan 16, 2019

README.md

bintray download build license

Expandable RecyclerView

RecyclerView implementation of traex's ExpandableLayout.

Download

repositories {
    google()
    jcenter()
}

dependencies {
    compile "com.hendraanggrian.recyclerview:recyclerview-expandable:$version"
}

Usage

demo

Create a row of your RecyclerView:

<com.hendraanggrian.recyclerview.widget.ExpandableItem
    android:id="@+id/row"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:duration="500"
    app:layoutHeader="@layout/view_content"
    app:layoutContent="@layout/view_header"/>

Create your adapter, which must extend ExpandableRecyclerView.Adapter:

public class MyAdapter extends ExpandableRecyclerView.Adapter<MyAdapter.ViewHolder> {

    public MyAdapter(LinearLayoutManager layout) {
        super(layout);
        ...
    }

    @Override
    public void onBindViewHolder(MyAdapter.ViewHolder holder, final int position) {
        super.onBindViewHolder(holder, position);
        ...
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        ...
    }
}

Have an ExpandableRecyclerView somewhere in your app, regular RecyclerView works too.

<com.hendraanggrian.recyclerview.widget.ExpandableRecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

Then pass LinearLayoutManager to the adapter:

LinearLayoutManager layout = new LinearLayoutManager(this);
RecyclerView.Adapter adapter = new MyAdapter(layout);

recyclerView.setLayoutManager(layout);
recyclerView.setAdapter(adapter);

License

Copyright 2016 Hendra Anggrian

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You can’t perform that action at this time.