A better ExpandableListView, with animated expandable views for each list item
A better ExpandableListView, with animated expandable views for each list item
Not happy with the Android ExpandableListView android offers? Want something like the Spotify app. This library allows you to have custom listview in wich each list item has an area that will slide-out once the users clicks on a certain button.
Repository at https://github.com/tjerkw/Android-SlideExpandableListView/.
Use a normal list view in your layout. You may also use a ListActivity or ListFragment
<ListView
android:id="@+id/list"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
The list item view should have a toggle button (Button view), and a target view that will be expanded. By default the expandable view will be hidden. An when a user clicks the toggle button the expandalbe view will slide out and be visible.
For example here below we have R.id.expandable_toggle_button Button view. And a R.id.expandable LinearLayout which will be expanded. Note that the expandable view does not have to be a LinearLayout, it can be any subclass of View.
…
In order to provide the functionality you simply wrap your list adapter in a SlideExpandableListAdapter. The adapter gets the ids to the more button, and the expandable view as parameters. This allows the adapter to find those views.
ListView list = ... your list view
ListAdapter adapter = ... your list adapter
// now simply wrap the adapter
// and indicate the ids of your toggle button
// and expandable view
list.setAdapter(
new SlideExpandableListAdapter(
adapter,
R.id.expandable_toggle_button,
R.id.expandable
)
);
In order to simplify the usage of this library, you can also use the mentioned ListViews directly in your layout xml file. The view itself will make sure the ListAdapter is wrapped in a SlideExpandableListAdapter.
See the sample app for usage information.
Add the library as a gradle dependency to your project.
If you have any contributions I am gladly to review them and use them if they make sense.
Licensed under the Apache License, Version 2.0
No open issues yet, or sync has not completed.