Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8159341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:52:31+00:00 2026-06-06T17:52:31+00:00

Hello I am trying to create a custom expandable listview, but the documentation on

  • 0

Hello I am trying to create a custom expandable listview, but the documentation on the adapter is very confusing and diverse. As usual, I have a hashmap to read the json array and then I put it on the list. The group of each child is sent within the same array in the key “GRUPO”, on the last position. Can someone please give me the adapter implementation to this? The code from the json follows below:

              if (tipopergunta.contentEquals("BOOLEANO") || tipopergunta.contentEquals("ESCMULTIPLA") || tipopergunta.contentEquals("ESCUNICA")){
                    HashMap<String,String> childdados = new HashMap<String,String>();
                    childdados.put("GRUPO", "Dados");
                    childdados.put("TIPOPERGUNTA", tipopergunta);
                    childdados.put("PERGUNTA", pergunta);
                    childdados.put("BREVEDESIGNACAO", brevedesc);
                    childdados.put("ESTADO",estado);
                    childdados.put("INSTRUCOES",instrucoes);
                    childdados.put("IDPERGUNTA",idpergunta);
                    Log.d("childdados",""+childdados.toString());
                    list.add(childdados);
                }


             if (tipopergunta.contentEquals("OPINIAO")){
                        HashMap<String,String> childdados = new HashMap<String,String>();
                        childdados.put("GRUPO", "Opinião");
                        childdados.put("TIPOPERGUNTA", tipopergunta);
                        childdados.put("PERGUNTA", pergunta);
                        childdados.put("BREVEDESIGNACAO", brevedesc);
                        childdados.put("ESTADO",estado);
                        childdados.put("INSTRUCOES",instrucoes);
                        childdados.put("IDPERGUNTA",idpergunta);

                        Log.d("opiniaolist",childdados.toString());
                        list.add(childdados);
            }  

           if (tipopergunta.contentEquals("FOTOGRAFIA")){
                        HashMap<String,String> childdados = new HashMap<String,String>();
                        childdados.put("GRUPO", "Fotografia");
                        childdados.put("TIPOPERGUNTA", tipopergunta);
                        childdados.put("PERGUNTA", pergunta);
                        childdados.put("BREVEDESIGNACAO", brevedesc);
                        childdados.put("ESTADO",estado);
                        childdados.put("INSTRUCOES",instrucoes);
                        childdados.put("IDPERGUNTA",idpergunta);

                        Log.d("fotolist",childdados.toString());
                        list.add(childdados);
                    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:52:35+00:00Added an answer on June 6, 2026 at 5:52 pm

    This is what helped me understand the expandable list view adapter.

    On a extendable list view you have always parents and children. When you click on a parent you see its children.

    So the adapter needs 3 things, mainly.
    A list of parents.
    A list of children (which can be for example an array of arrays)
    how to draw the children and how to draw the parents.

    you should have an array of parents: String[] parents = {"parent1, "parent2");
    and an array of arrays of childern, which, each array is children of one parent.

    String [][] children = {{child_A_Parent1, child_B_Parent1}, {child_A_Parent2, child_B_parent2}};
    

    on the method getGroup you should return the parent you want for a given row:

    public Object getGroup(int groupPosition) {
            return parents[groupPosition];
        }
    

    on the method getChild you should return the child you want:

    public Object getChild(int groupPosition, int childPosition) {
    
            return children[groupPosition][childPosition];
        }
    

    on the methods getChildView() you should inflate the layout you want (for example a xml with a textview) and set the text with the corresponding child. Note that here you don’t need to worry about which child it is already passed on the arguments:

    public View getChildView(int groupPosition, int childPosition,
                boolean isLastChild, View convertView, ViewGroup parent) {
       //inflate a the layout and get the text view
       tv.setText(children[grouposition][childPosition];
    ..}
    

    the same can be said about the parent method:

        public View getGroupView(int groupPosition, boolean isExpanded,
                    View convertView, ViewGroup parent) {
            //inflate a the layout and get the text view
    
           tvParent.setText(parents[groupPosition];
    
    }
    

    you can set all kinds of layouts for the parent and the children. Just use an inflater to inflate the xml from the layout folders. and then use the resource id’s to fill the views with your widgets.

    hope this helps you adaptiing your data to this snippet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i am trying to create aplication witch shows me sms in ListView but
What I've done Hello Guys, I'm trying to create a custom ListView layout. I've
I'm trying to create an Hello World JSF application. I have a bean with
Hello I am trying to create some simple pagination, but my php skills are
Hello I am trying to create a brush but I am having problem with
Hello I am trying to create an animation like creating heart like bubbles but
Hello guys! I have been trying to create a if/else statement code in jQuery
Hello Guys! I have been trying to create a cool Image Slider using Jquery!
Hello Guys! I have been trying to create a simple sample code for my
Hello I am trying to create a simple neo4j DB. I have a for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.