1. Create a new project in the Eclipse IDE from File ⇒ Android Application Project and fill all required details. I left my main activity name as MainActivity.java

2. 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.

5. I am using a custom adapter class to create list view. Create a new class file called ExpandableListAdapter.java and extend this from BaseExpandableListAdapter. This class provides required methods to render listview.

Hi there! I am Founder at androidhive and programming enthusiast. My skills includes Android, iOS, PHP, Ruby on Rails and lot more. If you have any idea that you would want me to develop? Let’s talk: ravi@androidhive.info

yes but..when in the adapter i set the listener it wont listen!!! you know why?

Filipe Tagliacozzi

Ravi… excellent work… Anyone can make great apps relying on codes presented here. Through people like you we will be increasing the overall quality of android apps. I particularly have a easier learning when altering ready codes and making changes to see the behavior .. Congratulations…. I will click all the sponsors that I can.

but when I run the project it doesn’t show the indicators.
If I try to click the header this action generate the following error:

Unexpected error while launching logcat. Try reselecting the device.] device not found
com.android.ddmlib.AdbCommandRejectedException: device not found
at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.java:752)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:373)
at com.android.ddmlib.Device.executeShellCommand(Device.java:462)
at com.android.ddmuilib.logcat.LogCatReceiver$1.run(LogCatReceiver.java:109)
at java.lang.Thread.run(Thread.java:724)

any help?
Thanks

Ben

Seems like your device is not detected by your Operating system,try to install appropriate device drivers first

Excellent tutorial! Is just what I was looking for, I want to modify a bit your listview, I pretend to put some buttons in the listview or set an onclick event, Could you help me with that? I need to develop a menu for a restaurant and it’s necessary for me that the program counts the clicks on each product. I hope you can help me with this task .

akhil nair

Hey Ravi good tutorial i want to know how to create ExpandableListView with image and text else a coustom ExpandableListView

Thank You

Andy

how to set onClickListener(intent) for any particular child option

rahul

nice tutorial..please keep it up…

Angel

Hi!

First, thank you for a very great tutorial. As a beginner in Android, you have been a great help to me.

I am currently trying to make your program into a dynamic expandable listview with data coming from a remote server accessed through PHP and JSON (using your other tutorial as reference). However, I’m having problems trying to save the data on the listDataHeader and listDataChild. Could you please share some tips on how to resolve it?

Thanks again and more power!

Joseph

hi, what if I there is a add button? do you have source code for this? thanks a lot! 🙂

sravani

hi nice blog spot , how to implent Expandable List view up to Four levels

Daan Dawud

Fantastic dude! Im going to attempt to use this with the Navigation drawer. Hopefully it shouldn’t be too bad.

Mike

Ravi => Android Sensei !!!

Der Ääl

1st thing: great work, thank you so much!
2nd thing: i tried to put a 2nd textview into my childrow.xml but it doesn’t work. i think i’ve made a mistake in the getChildView or in prepareListData… can you (or maybe anybody else) please help me?
would be great!
thank you

MrBoomBostic

“No Empty Constructor” ???

Helmer Plaza

Hi..how do i apply this on a fragment?? where do i put it?on the onCreate or onActivityCreated?

mike20122012

Awesome tutorial..:)..This really helps a lot.
How can I implements this when using fragments? Help would be really appreciated..:)

Ashish

Very useful article but there is one problem in each article. Problem is that the width of code box is very less so we have to scroll horizontally again and again. so please make it wider if possible

The best tutorial !!
When i scroll the list item i have a white background. To fix it add the following attribute android:cacheColorHint=”#00000000″ in the xml file : activity_main.xml in ExpandableListView view

Nice tutorial thankyou but how do i add a second textview to the childview.I mean adding it is easy (you just have to edit the XML) but i don’t understand how to set the adapter to make text appaer in the second textview.

systemz

I want a second childview too and a textview in every group please…

amala ray

Hey nice tutorial, can you tell me how to add empty views as children of every listview element. So that when i click on an item which does not have children, the application does not crash.

Abdullah

Thank a lot for this codes, works perfectly, it was soooo helpful for me, I was desperately looking for codes, thanks again. 🙂

Senjo

Thanks a lot.

ALB

Thanks for this super helpful tutorial!! For those asking about putting in a fragment, I managed to get that working, so thought I would share: (1) fragment extends ListFragment, (2) create a new layout for the fragment with same code as described above for activity_main.xml except change to “android:id=@android:id/list” and inflate this layout in onCreateView in the fragment (3) put this in onActivityCreated:

But there is one problem when changing the orientation.
Follow this step to reproduce it :
keep one tab expanded. Now change the orientation of your phone.
Now try to expand another tab. So it won’t collapse the previously selected tab and. So at a time 2 tabs will be expanded….lol

Rishil

@ravi8x:disqus : How can i implement Search filter Functionality to Expandable listview. ?

error is “The method setAdapter(ListAdapter) in the type ListView is not applicable for the arguments (ExpandableListAdapter)”. What i’m doing wrong?

systemz

“New” is missing after “listAdapter =”

Richard

Ok so after taking a good look on this one I was wondering if we could integrate this project on the Drawer navigation. Like for example; we have five default items on the drawer navigation and below that are set of expandable items. Hey Ravi is that possible to integrate this in a Drawer Navigation? I mean both of them are list views right?

Ivelfan

Awesome article !

Many thanks !

Harish

Hi
I want to do expandable listview like tree view..
It is possible to do?

prabhakaran

very nice tutorial………. but i want, if suppose open a group once at a time, other groups are collapse

Tharaka Nirmana

Thanks a lot, great tutorial. After 2 days of research this tutorial helped me to get what I want finally. Thank you!

Sohail Zahid

Again Thanks A lot Ravi………..

Nadir Ali

brilliant code to help me, and solve the problem

Developer

How do i insert a radio button in the child item of the list view?

Guest

Hi Ravi, Thanks for this, how can I put subtitle in the parent header?

Aj

Hi Ravi, Thanks for this, how can I put subtitle in the parent header?

Illuminate

how would i open the list item up in a fragment, or another window, where it would display images and possibly a write up

JP

Great tutorial..How could you add checkboxes to the children?

Luis Alberto Romero Calderon

Awesome tutorial. very clear. Thanks

Pradeep

This is great…. Very clear and usefull items, Thanks much for doing this….

silver

I have tried to use a EditText inside ExpandableListView but after adding this Group is not expanding on click. Anyone has any idea about this?

Gold

$(“article”).css(“width”,”1000px”);
Run this in the browser’s dev tools to expand the article’s width. Easier to read code this way.

Vick

Trying to hide and embed the database primary key behind the values that are being used to populate the children data. Want to create and Edit item page similar to how you did on list view. How do I store and send that?

I just want you to know, that after hours of looking for a tutorial on how to do this.. I finally navigated back to you, my default android tutorial man… and my god. Your code is beautiful, it’s explanations are great and its easy to follow. THANK YOU SIR.

amit

Nice Tutorial Thanx

Suare

Nive Tutorial man! I implemented it with Fragments

Lisa

You are a good writer. Clear and straight to the point tutorials. You should compile all your work into a book. Be blessed.

Fedro

Thanks for this. You are a good programmer and an excellent teacher. Your tutorials are very clean and easy to understand.
Has anyone an example of how to implement ExplandableListview retrieving data from a JSON array?
I suppose that it will be useful if update this example explaining how to work with dynamic data.

JJ

Hi, can I do multiline textview for children?
Thanks

Hung Tran

i don’t see icon of expand listview?

anusha

can u tell me how to make auto close of one list when other one is clicked…..

Juwar74

Can you extend this article to include moving to another screen when one of the children are clicked. I’m not sure how that works actually. I would need it to move to another screen

Hardik Trivedi

Thanks a ton.. It helped me a lot!!

Kalu Khan Luhar

Thanks Ravi , your tutorials helped me a lot. One question is that how to expend/collapse list with smooth animation.

Krits

Hello and thanks for the nice tutorial! I am using this layout for a project and I am experiencing a problem! I have managed to change the background colour of each parent(and child) to transparent but when I click on the parent(or the child) I am getting that yellowish colour(only during the click) which doesn’t match the blue theme of my app. I’ve searched everywhere and cannot find how to change it to transparent as well. Any help would be much appreciated!

Wasim Amin

@Krits: use this in your listview
android:cacheColorHint=”@android:color/transparent”

Vladimir Topalovic

hi Ravi. I am looking to learn how to use expanable list, for some time and this exampe is the best one, that i can find on net. Can you please help me?

for a week i am trying to animate expand and colapse for Expandable list and i done all exept for moment when auto-scroling is activated. when i expand list on bottom off screen, list auto-scroll on bottom of group and it totaly mess my animation. how can i stop that auto-scroll. I alredy tryed android:transcriptMode and setTranscriptMode(0). Please help me i do not have any other way of reseach it more.

Sino

how can i set images to parents and childs?

Guest

To add images to either parents or children or both you would have to add an ImageView into their respective xml layout files – list_group.xml for parents, list_item.xml for children.
Here don’t forget to use margins to place the image where you need it.
You can also place a drawable in the xml thus making all your items have the same images. Alternatively, you could assign image resources to each through code, which might add a little more flavour to your project, but is more involving.
Good Luck!

Jake

how to parse names from json file to expandable list? thanks.

saravanan

How to give scroll to group items instead of whole exapndable listview

Anon

I keep getting, “ExpandableListAdapter” is abstract can’t be instantiated. On this line, “listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);” Any solutions?

Your Fragment is importing android.widget.ExpandableListAdapter, Remove that.
First create the class ExpandableListAdapter then Write
ExpandableListAdapter listAdapter;
listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);
May be Class ExpandableListAdapter is clashing with interface android.widget.ExpandableListAdapter or change the name of the class ExpandableListAdapter to something else.

nishant

#Help

Hello friends , can any one tell me how to add expandable list view in existing fragment(As in case of Navigation drawer I’ve fragment class ).Do I need to create new activity or can I add the above MainActivity code to
the existing fragment class.

Aleksandar Petrovic

Incorporating this into your project will not be as straight forwards as simply pasting the code into your fragment.
You need to create the class, per Ravi’s example. Once you have the class made, you can then add the listeners from his MainActivity into your fragment. Do note because Ravi extends an activity and not a fragment there will be some minor changes that you will have to handle. This is not hard and the errors should clue you in as to what changes have to be made.
(Hint: in the listadapter line instead of ‘this’ you will most likely need to replace it with ‘getActivity()’) or something to that effect.

i want a button in group_item.xml class.listview should expand when i press the button not by clicking the listrow.i added my button in xml but dont know how to set clicklistener.kindly help me by writing code…..

thanks but i already finished that project and I decided to activate onlick on an entire row but i got a new project which i think such functionality is required(clicking on list item child views) I’ll check on it thanks

how do i customise the listview? i want to change the colour and background of the listdataheader

Eduardo

the list indicator are not displayed in api 10. How do I solve it?

Luzi

Hey ! Thanks a lot for this example ! I used it for my application and it works fine 🙂

But (there is alway a but 😀 ), I would like to implement a filter only on the Header Datas, but I don’t know how. I tried different code founded on the web, and adapted it to my code, but it didn’t work.

Can you help me, please ?

Thx, Nico 🙂

MRK

Hi Luzi,
Do you have any solutions for this ?
I have same problem and don`t find useful issue in internet.
So I want to implement filter for child data
Can you help me ?
Tnx 🙂

arun

Nice Example.. Thanku.. I need show some items (for example 2) on collapse instead hiding all items. What to do?

yash sharma

Its not Working for me the logcat says “Your Content must have listView”

J Bala Prakash

how to use expandable view in sqliet db help me…..

Vijayadhas

Hai.. Is there any example for sliding menu with expandable view??

rahul

how can i do same thing when click on slidenavigation menu after that i want to see expandable view

Bharath Reddy

Excellent.thanks

manvi gautam

heyyyy .. i wannna use multi line text how can i use in this …
GA-KHYIL HOUSE

Fax: 0091-11-238-111-49
how to use this under a single header….
plzz rply asap …..
thankssss a lot in advance

ancy

hi wan know is that possible to expand child data ?

Sivan Kumar

Thanks … Good Work

Salman Mohammed

Is it possible to add children strings from (R.string) or Arrays(R.array) in order to support other languages, instead of using (” “)?

Văn Lý Vũ

Thanks for this post, it’s very helpful. I did it and it worked. But i want to extend a little bit. That i want to add a footerView to childView. Now what i do is:
1. I create a layout file name footer_view.xml
2. Then for each parent item, i add one more element to listChild.
3. In getChildView method, i check
if (childPosition == getChildrenCount(groupPosition) – 1){

//render footerView here
}else{
//render normal child item
}

But seem it doesn’t work. When i click the parent first time, it works, but the second time it show error: NullPointerException.
Did i do anything wrong?
Thanks for your time.

ati’atul maula

It’s good tutorial. I have trouble to make arrow icon on ExpandableListview, I have used android:groupIndicator but the image result is too large. Can you tell me how to set height and width it?

can we do multi-layered expandablelistview with Json response array data.?

Steve

Why are you mixing fill and match_parent that often?

jayant rawat

What to do if data is coming through json please suggest me

Ion Popescu

I followed the “How to connect Android with PHP, MySQL” tutorial. I successfully populated a database with some test values. Now I need to make a list like this above, with “name” as List header, and ‘price” and “description” as Child, (to appear when I touch the “name” and list is expanded). I preserved tags from the other tutorial, so it will be more clear what i want to achieve. I am a very beginner at android, so I have no idea how to fetch those data, and populate the list with all the names, prices, etc. Can someone help me? 🙂

Animis

how do I add a LongClick listener to the Group and CHildren? I want to be able to add items to the list by long clicking on the group and then typing something in

Aayushi

hey hi ,Android hive is a great site.Hats off to writer.
I made the expandable list view acc to your tutorial but what i have to do if I want to populate Expandable List View with values from database?Means what changes I have to do in MainActivity.java add() .Will be of great help.Waiting for your reply

How to add onClick to items inside the row.
for eg TextView and Button in inside RelativeLayout

Lily

you can add onclick listener inside getchildview method

Gilgw

I just tried this tutorial with Android Studio 1.1. RC1 but running the application throws me the following error:
java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
Any idea why?

Shuvo Joseph

Attempt to invoke virtual method
‘void android.widget.ExpandableListView.setAdapter(android.widget.ExpandableListAdapter)’ on a null object reference at
com.XXX.YYY.ZZZ.NavigationDrawerFragment.onCreate(NavigationDrawerFragment.java:159)
Which is
expListView.setAdapter(listAdapter); // line 159
where expListView is ExpandableListView and listAdapter is ExpandableListAdapter.
//listAdapter initialize
listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);
This is written in NavigationDrawerFragment which extends Fragment.

Shuvo Joseph

Solved it. Thanks for the tutorial 🙂

aman mehta

how?? i am facing the same issue

mortenslotthansen

Consider moving inflator instantiation to constructor and then use parent as 2 argument when calling inflate ie.

Is it mandatory that the both child and parent/header list should be equal in size ?

Mike Michaels

Do you mean text size? No. modify list_group.xml, add some sample text, this text gets replaced in the code but you can use the preview panel to see you changes.
android:text=”Test Group”
android:textSize=”40sp”

Mrinal

This is awesome! Just wanted to know how to make it scrollable when my screen has few linear layout along with one explandable list view.

Mike Michaels

android:smoothScrollbar=”true”
in the activity_main.xml under ExpandableListView

Abdullah

Hi ravi , i want to know if i have second text view in the child, how can insert data to that, how can i customize the adapter

Dheeraj Bansal

I want to make slide menu with expandable list like as flip cart app slide menu.Please guide me.

Ajinkya

Can you please tell something about the Check boxes in Expandable List View and how to give functionality to them means how to get the checked states of those check boxes and use their values. This is only doubt i am facing 🙁 ….

Kenny

Hi All,

I am going through this tutorial, and everything is working fine, However i am stuck at the following:

I want to pull my listview items from a JSON feed as in Ravi’s tutorial “android-json-parsing-tutorial” where i would like the heading as the Persons name and on expand the persons info.

I really don’t know how to change from a typed array to a dynamic array, any pointers will be appreciated

Kenny

MRK

Beautiful code !

Hi Guys ,
Can any help about ” Implement Filterable on Child ” for this code ?
Thanks a lot .

usarrr

why cannot resolse symbol ‘R’ ?

Please Help Me.. :'(

Jose Pablo MB

Usually this happens when there’s an error in any of your XML files. Try looking for an error in any of your XML files, to check if there’s an error
Hope this helps!

GregKorman

Other possible solutions include cleaning and then rebuilding your project. Also, try restarting your IDE. Sometimes it can be caused by files getting out of sync with the IDE.

Erich M.

USARR, make sure your project or package path is correct. That is where the problem is. Try re-importing the class paths by right-clicking on the “R” code that is give the error and clicking “import”. This should fix the problem.

Kishor Ramani

go to project->clean..

and see the result.
may be it will help.

Niso

I am trying to get the Child’s position, how can I get it?

Jose Pablo MB

You have to set the onChildClick listener for the ExpandableList. The attribute called “childPosition” is the one you’re looking for.
Hope this helps!

for this you have to use auto complete text view rather than edit text.
when customer start enter your postal code he/she see some list of postal code.

and on button click event
you have to match this postal code with your database and retrieve list of restaurant which is in this area.

prasanna

Excellent.. Nice

The Pen is Therapist

So, I want to click on what you have as movie titles and have it go to text. Something like:

Title
Name1
Name2
Phone 1: 555-555-5555
Phone 2: 555-555-5555

amit sharma

Thanks for the post, this is very nice. But what i have to do if I want to add custom list_item like textview with image.
Please Help me regarding this, thanks in advance

Josh F

To add an image to your groups, in the list_group.xml file just add the layout that you want that cell to be. In your case you could just add an ImageView next to the TextView. Then, in the getGroupView method add whatever image you like to the ImageView you just added to the xml. Do it the exact same way for adding images to the child views except you will edit the list_item.xml and the getChildView method instead.

jerofad

Hello Josh. How can I add different images to the child views. Since I have more than one list item and they are to have different images. please help me out. Thanks

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2449)

at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2509)

at android.app.ActivityThread.access$900(ActivityThread.java:172)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)

at android.os.Handler.dispatchMessage(Handler.java:102)

at android.os.Looper.loop(Looper.java:146)

at android.app.ActivityThread.main(ActivityThread.java:5694)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:515)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)

at dalvik.system.NativeStart.main(Native Method)

Caused by: java.lang.NullPointerException

at mikecoding.nl.mynewcleanapp.MainActivity.onCreate(MainActivity.java:51)

at android.app.Activity.performCreate(Activity.java:5541)

at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)

at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2509)

at android.app.ActivityThread.access$900(ActivityThread.java:172)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)

at android.os.Handler.dispatchMessage(Handler.java:102)

at android.os.Looper.loop(Looper.java:146)

at android.app.ActivityThread.main(ActivityThread.java:5694)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:515)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)

at dalvik.system.NativeStart.main(Native Method)

Anand

I want to add one more level can you describe me how can this possible

Ullas Ms

Hi .how to implement onclick lIstner on listAdapter.My data is coming from squlite I want show half the data in first activity and reamining in second activty using onclick lIstner in list adapter

Marco De Roni

Hi, fine and smooth. What if I wanted to inflate a layout once a child is selected?

Åíshå Håméèð

I want to remove the childitems alongwith the group em removing.. i have removed the groups but unable to remove childs.. and childs are shuffling dont knw why 🙁

Åíshå Håméèð

please Ravi help

Ajay Panchal

Is that possible to use radioGroup as a child instead of TextViews?

Dantalion

Hi whenever I add an header entry with the same name as another header, All the child items will have the values of the first header entry how do I prevent this?

rotexhawk

Is it possible to add the default group indicator. My emulator doesn’t show the indicator ?

Akshay kumar

Is it possible to add a html file in the child list.

Saurabh Panchal

Can you please tell how to implement search feature to this expandable listview ? I have been trying but not successful till now.Please share some tips.Thanks.

Vinayak Parab

I Also want to add search option for this example

jhansi laxmi

nice example ravi

Lalith Narayan Kashyap

Hi Can anyone help how to move the icon to the right ?

Akshay Patil

How to hide the dropdown indicator when no child element is present

James

expandableListView.setGroupIndicator(null); // hides the arrow

Akshay Patil

I already tried that…what i wanted was to hide arrows for only non-child groups and not all groups. I used custom png arrows as indicators in the end. But still if theres a solution for using inbuilt indicators, i would like to hear it from you. Thanks.

U’re importing ExpandableListAdapater from android. U have to import the custom ExpandableListAdapater that u wrote.

sameer

Hi Ravi..
how can i remove arrow mark for non Expandable listview.
There is any Example….

Kaiko

Hi,

Can someone tell me if it is possible to have several columns in an ExpandableListView?

Thanks 🙂

mooi

you can add multiple ExpandableListView

Dhaval Chheda

Hi ,

I added some more list data to be shown in the expandableListView but that data is not getting expanded so please assist

do i need to use notifyDataSetChanged() ?

I tried to use it but it did not work

Please assist

CSP

see above^

CSP

if you use Checkbox into Expandable view, add focusable = false

Johnny Dude

Why? The purpose of adding a checkbox would be to let the user select one or more items. What is the issue your addressing? Thanks.

Rishabh Maurya

Hey Ravi ,
I want to use searchview functionality in expandable listview similar to you .
Whenever the user types any term , the group should automatically inflate and highlight the matching child item .

Dinesh Bhat

Hi All, I extended this sample to support checkboxes in the expandable List View. It was hard to find any samples with checkboxes.

Sir these code i am trying. Issue is that when i am using the onclickchild it shows the details in jelly bean version when i am working in kitkat version it is not working. Means i can’t able to scroll to see the list.

Zen Bhatt

Hi Ravi, thanks for this great tutorial. I want to apply some style on some of the child views based on some condition. Like this,

listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
Hi. i have an error on this one saying it is abstract and cannot be instatiated. what should i do?

kr

did you solve this?

Raja Malik

I make multilevel Expandable list view with dynamic bulk of json data …but data is show all groups, chides and sub childes correctly. but issue is child data repeat.if child have ten item then child data repeat ten time.. the problem is not found….can you help me…

But now the listDataChild is added as many times as the size of the ArrayList is (9 in the case). May you help me figure it out? Thanks!

ravikiran

Hello Ravi,

i am using the code above, in that list group i added a button. i cant abele to give that button action or that button intent . in expandable list one row one button we added only one button. that buttons to next activities i have to give cunnection. help me thank you

Sankar Santhanaraman

Hi Ravi – Thanks, this code works like a charm. Appreciate you adding the code for click, collapse and expand group. Can you also add the piece of code for adding an edit text as a means to filter this expandable list view? Thanks.

if child is empty. it give an error at size of child. how to rectify the code.

In my list some items have child but some is empty.

Also how do i make it already expanded if having child.
Please Help
and thanks for this tutorial
Thanks in advance.

savy

I have tried above program but it does not show any output because app has been crash and it android monitor shows this problem
Caused by: java.lang.NullPointerException
at com.example.hp.kludge.ProgramList.onCreate(ProgramList.java:36)

please tell me sir how to resolve this problem….its very urgent for me please help…please!!

aman mehta

did you find any solution , i am having same issue

prasad Vdv

Hi its working fine, Thanks for the code
Can we expand the all groups by default.
Please let me know..

Prathibha Nandini

Hi @ravi8x:disqus I wanna do this in fragments. Fragments of your material design. Could you help please

plu9in

Hi,
You don’t need to keep a reference on the context in ExpandableListAdapter class. Apparently, you keep it to access the inflater service. You can just do this: LayoutInflater.from(parent.getContext())
Like this, you avoid a memory leak 😉
Have fun coding !

Hi Ravi, I have one issue.
How to handle the header item click when it is not having any child inside it.
Please help.

raj

how to implement multi level expandable list view

Nikhil Gupta

hello sir, i am new in android so please help me. I am developing the Basic Activity in which i create the 4 layout file.
1. activity_main.xml -(create an expandable list view)
2.child.xml
3.prent.xml
4.number_picker.xml
and One is MainActivity.java file and Second is MyAdapter.java.
i want when number is Select in number picker data will be show According to the number in number picker like when select 2 then only two parent show and with also child. and i have Edit text – Patient Name , Patient Age and Patient Gender. and when Focus change then data save in listview( means i want to save temporary data in list items)
please help – nikhilgniit@gmail.com

Nicky Apriliani

How to make multiple selection in the childview then?

Mayank Sahai

did you found the answer for that?

Suman Ghimire

Within ListView i have to use TextView,TextView,ListView.I am not able to work list Within List.Can this Problem be solved Through Expandable ListView????

Noob

Great tutorial man, I copied your ExpandableListView code, passed in a different set of input, but the list view didn’t expand, found out that the checkbox I had in my list_group.xml was causing the problem somehow

Jacek Budzynski

Hi, great tutorial but I have a question.
How can you display just a single item from a child list under corresponding header? So let’s say that in your example you’d for example use listDataChild.put(listDataHeader.get(2), comingSoon.get(2); which obviously doesn’t work because of the ExpandableListAdapter constructor that can’t be changed because then getChildrenCount and getGroup methods from that class won’t work. Any help would be much appreciated.

@ravi8x:disqus Great tutorial ! but could you make it if u get JSON data from mysql ?
Because there s no ever any tutorial ..all tutorials are static one and manually adding items to expandablelistview ..

That is how the exapandable listview is designed. Try achieving the same using RecyclerView as ListView is deprecated.

Rasmus Norup

In other words its just badly designed?
The visual design part of android studios even has “entries” as the very top field of ExpList, but as far as I can tell, putting anything in there will crash the app.

I understand that you need strong java-fu to do the sort of advanced stuff that many developers would like. But having a standard implementation that just populates the list(like with ListView) from XML seems like a no-brainer.

ListView works just fine for me, with pure XML.

I had some problem with this, but in the end it turned out I just needed a spinner instead, and everything was well in the world 🙂

Just read the data from Sqlite and add them to a ArrayList (which is used for adapter) and call notifyDatasetChanged to refresh the list.

Jorge Américo Vargas Freitas

Could you elaborate more on the subject?

This template here is perfect to receive a detailed database and it’s hard to find content about it online.

I’ve been searching like crazy and there isn’t good solutions around, so, I can tell you pretty well (I tried Realm, Room Persistence Library and some different kinds of SQLite databases already).

For instance, a prepopulated SQLite database with like 10 fields would work pretty well in a ExpandableListView like the one this tutorial explains.

shravan kumar

Hello Ravi… is it possible using ExpandableListAdapter in RecyclerViewAdapter class ?

RAHUL

Hi. Thank you for the tutorial. Can you please guide me as how to dynamically add Group(s) and its respective Item?

Purvish Jariwala

Hello Ravi your tutorial is really very helpful but, can you please tell me how to change that indicator on click list item.?

Purvish Jariwala

I got it..how simple it is.!!

Reinhard Doberstein

Hi,

I have the same question. How to set the icon in the list_group.xml. Unfortunately it isn’t part of your sourcecode. Do i have to set it ‘by-hand’ in the onGroupExpand() and onGroupCollapse() methodes?
Thanks for all your work.

I just use device screenshot button combination and use Photoshop to edit them.

jo

hi Ravi . i am actually building a mobile app for my school and i would like to have a home page like facebook’s. where students can actually post some pictures and videos and so on… i would like to know which option would the best to implement the layout and which component can i used. thank you

Thank you for the good tutorial.
For me, everything works but I would like to put the expandableListView into a fragment
Problem is that if I put the onCreate part into the onCreateView of my fragment, the expandbleListView is just not visible in my app (I tested if the issue would come from the integration of the fragment or the layout by displaying a textView in the fragment, but that worked).
I also can’t put the onCreate part into the onCreate method of my fragment, because I then, I can’t initiate my expandableListView.