Expandable Recycler View in Android

Expandable Recycler View Android



private fun initializeChildRecyclerView(childRecyclerView: RecyclerView?)
private fun onCreateParentView(parent: ViewGroup, viewType: Int):PVH
private fun collapseAllGroups()
private fun reverseExpandableState(expandableGroup: ExpandableType)
private fun collapseAllExcept(position: Int)
private fun handleSingleExpansion(position: Int)
private fun handleExpansion(expandableGroup: ExpandableType, position: Int)
private fun setupChildRecyclerView(holder: PVH, position: Int)
fun setExpanded(expanded: Boolean)
fun addGroup(expandableGroup: ExpandableType, expanded: Boolean = false, position: Int = -1)
fun removeGroup(position: Int)
private fun View.getRecyclerView(): RecyclerView?
private inner class ChildListAdapter(private val expandableGroup: ExpandableType, private val parentViewHolder: PVH, private val position: Int, private val onChildRowCreated: (ViewGroup, Int) -> CVH ) : RecyclerView.Adapter<CVH>()
abstract class ExpandableViewHolder(override val containerView: View) : RecyclerView.ViewHolder(containerView), LayoutContainer
abstract class ExpandedViewHolder(override val containerView: View) : RecyclerView.ViewHolder(containerView),LayoutContainer
abstract fun onCreateParentViewHolder(parent: ViewGroup, viewType: Int): PVH
abstract fun onBindParentViewHolder(parentViewHolder: PVH, expandableType: ExpandableType, position: Int )
abstract fun onCreateChildViewHolder(child: ViewGroup, viewType: Int): CVH
abstract fun onBindChildViewHolder(childViewHolder: CVH, expandedType: ExpandedType, expandableType: ExpandableType, position: Int )
abstract fun onExpandableClick(expandableViewHolder: PVH,        expandableType: ExpandableType)
abstract fun onExpandedClick(expandableViewHolder: PVH, expandedViewHolder: CVH, expandedType: ExpandedType, expandableType: ExpandableType )
protected open fun isSingleExpanded() = false
abstract class ExpandableGroup<out E> { /** * returns a list of provided type to be used for expansion. */ abstract fun getExpandingItems(): List<E> 
/** * Specifies if you want to show the UI in expanded form. */
var isExpanded = false

How to run ?

Last Step

Software Engineer II (Android) @ Careem || Fitness Freak for 9 years

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store