Can we have 3 different ExpandableLists in same layout i.e., in main.xml? If so can we use them differently in terms of android:list?
I have a requirement that I need to implement 3 individual expandableLists in the same layout. Can it be done?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes you can. I imagine simply using different ids would be more straight forward than android:list. But I wonder, are you trying to achieve an expandable list with 3 group rows and 1 group of child rows under each? Such that these are connected and look seamless? If so you can do it with one expandable list. Just an fyi. If that was your intention, I’ll get you a sample code to show you how it’s done. It’s very easy.
EDIT: The reason you are getting that error is because you’re most probably trying to use an expandablelistactivity class, which assumes (practically) that there will only be one expandable list in the activity. You should use a regular activity class. Here is what i’ve just tested and works.
I’m posting the xml as well, in case I wasn’t being clear about the id instantiation (PLEASE take note — Although i used “wrap_content” for the layout_height in the xml for the sake of speed, it is DEFINITELY not best practices to do so for expandablelistviews or any listview, it uses much more resources than the other alternatives would):
And here is a picture