Generally when we deal with menu’s which are to be show in listview,Sometimes we need to show sub-categories so for this purpose we will deal with android Expandable Listview in name itself says that it will be expanded depending upon categories.

Categories are shown as group headers and sub categories are shown as child items.

 

expandablelistview1

I have shown a ExpandableListview which contains three categories

 

  1. Sports
  2. Colors
  3. Animals

Which are further sub categorized for example:

expandablelistview2

Creating android ExpandableListviewAdapter File

ExpandableListAdapter.java

 

  Assigning expandableListView set onClickListener for group click and child click.  

MainActivity.java

 

  Adding ExpandableListView to  activity_main.xml.

activity_main.xml

 

Adding parent (Group Header).

parent_item.xml

 

Adding child_item to listview

child_item.xml

 

Output :

device-2016-04-08-164814

Group and Child On Click Toast

 

device-2016-04-08-164849 device-2016-04-08-164932

device-2016-04-08-165109 device-2016-04-08-165233

device-2016-04-08-165311 device-2016-04-08-165355



Share article on

Show Buttons
Hide Buttons

June 27, 2017

Attention Required! | Cloudflare

One more step

Please complete the security check to access push.wppush.co

Why do I have to complete a CAPTCHA?

Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

What can I do to prevent this in the future?

If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

Clear all
Read previous post:
push notification
Android Push Notification Tutorial For Beginners

Close