What is Expandable ListView?

What is Expandable ListView?

android.widget.ExpandableListView. A view that shows items in a vertically scrolling two-level list. This differs from the ListView by allowing two levels: groups which can individually be expanded to show its children.

How to make ListView Expandable?

In order to create an expandable list view, we need three xml layout files. First one is for main listview, 2nd one for list view group item and 3rd one is for list view child item. Open your activity_main. xml and add ExpandableListView element.

What is expandable list view in android?

In Android, ExpandableListView is a View that shows items in a vertically scrolling two level list. Different from the listview by allowing two level groups which can individually be expanded to show its children. Each group can be expanded or collapsed individually to show or hide its children items.

How to make Expandable view in android?


  1. Step 1: Create a New Project in Android Studio.
  2. Step 2: Add the CardView Dependency.
  3. Step 3: Add all the Required Drawable Resources in the Drawable Folder.
  4. Step 4: Modify the XML Layout.
  5. Step 5: Modify the Java File.

How do I make my RecyclerView expandable?

Steps To Create Expandable Recyclerview

  1. Adding Dependencies.
  2. Prepare data for the recyclerview.
  3. Design Header & child items layout for expandable recyclerview.
  4. set data into expandable recyclerview.

How do I create an expandable list in navigation drawer?

If you want to achieve above behavior to your NavigationDrawer you can follow below steps:

  1. You have to add Expandable listview to your NavigationView.
  2. Create Header View.
  3. Create Child View.
  4. Extend BaseExpandableListAdapter.
  5. Set Adapter in MainActivity.

What is a ListView in android?

Android ListView is a ViewGroup that is used to display the list of items in multiple rows and contains an adapter that automatically inserts the items into the list. The main purpose of the adapter is to fetch data from an array or database and insert each item that placed into the list for the desired result.

What is expandable RecyclerView?

Expandable RecyclerView is one of the most important feature in Android which can be easily created for our application . It contains two views one is parent view and other is child view. Parent is visible by default but the child view has to be expanded and collapsed. It will expand when we click on parent view.

How do I use RecyclerView?

Using a RecyclerView has the following key steps:

  1. Define a model class to use as the data source.
  2. Add a RecyclerView to your activity to display the items.
  3. Create a custom row layout XML file to visualize the item.
  4. Create a RecyclerView.
  5. Bind the adapter to the data source to populate the RecyclerView.

What is sub menu android?

Creating Submenus A submenu is a menu that the user can open by selecting an item in another menu. You can also use addSubMenu() to dynamically add a SubMenu to an existing Menu. This returns the new SubMenu object, to which you can add submenu items, using add(). Explore Android Sample Resumes!

Is ListView deprecated Android?

While the ListView is still a very capable view, for new projects, I’ll strongly advise you use RecyclerView, and consider the ListView as deprecated. I can’t think of any situation where the ListView is better than the RecyclerView, even if you implement your ListView with the ViewHolder pattern.

What is difference between ListView and RecyclerView?

Summary. RecyclerView has greater support for LayoutManagement including vertical lists, horizontal lists, grids and staggered grids. ListView only supports vertical lists. ListView starts by default with dividers between items and requires customisation to add decorations.

How to create an expandable listview in Android?

Android ListView Custom Adapter 34. Android ViewFlipper 35. Android ButterKnife 36. Android Non Scrollable ListView 37. Android JSONObject 38. Android XML Parser 39. Android Runtime Permissions 40. Android Data Binding 41. Android Data Binding Advanced 42. Retrofit Android 43.

What should height be in expandable list view?

The height should be in dp, sp or px. 4. listSelector: This property is used to set the selector of the expandable list View. It is generally orange or Sky blue color mostly but you can also define your own custom color or an image as a list selector as per your design.

How is ChildInfo used in expandable list view?

ChildInfo is a model class used to set the name of the child item and the sequence of the child item from your main activity and then get the name and sequence within adapter class. Finally set the value to expandable list view.

Can you use wrap _ content in expandablelistview?

Important Note: You cannot use the value wrap_content for the height attribute of a ExpandableListView in XML if the parent’s size is not strictly specified. In other words we mean if the parent were ScrollView then you could not specify wrap_content since it can be of any length.