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 7904891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:16:17+00:00 2026-06-03T10:16:17+00:00

I have a big problem and I have been searching on the web to

  • 0

I have a big problem and I have been searching on the web to have a good solution for this problem but I couldn’t find any approach for this problem so I want help.

I need to use expandable list view which get data from server (JSON Array) and i have categories, GroupData and its items, ChildData. I don’t know how to get the child data for each parent group… i need something like SimpleCursorTreeAdapter but i didn’t find anything.

This is what i reach for till now but it’s not working so please help me:

      static ArrayList<HashMap<String, String>> mapList = 
          new ArrayList<HashMap<String, String>>();
  static ArrayList<HashMap<String, String>> catItemsList = 
          new ArrayList<HashMap<String, String>>();
  static ArrayList<ArrayList<HashMap<String, String>>> ItemsList = 
          new ArrayList<ArrayList<HashMap<String, String>>>();
  static   ListView order_list;
  static ExpandableListView order_items_list;
  static  SimpleAdapter adapter,ItemsAdapter;


protected void BindOrederItemList(final int order_id) 
    {
        // TODO Auto-generated method stub
        //select all categories from order items where order_id =??
        //select items where category=??

        JSONObject params = new JSONObject();
        //int    no_pepole=Integer.valueOf(noOfGest_txt.getText().toString());
            try
            {
        //  params.put("order_status",myStatus);
         int rest_id=prefs.getInt("Rest_id", 0);
            params.put("order_id", order_id);
            params.put("lang_id", 1);
            params.put("rest_id", rest_id );
            //params.put("order_status", 0);
        //  params.put("noOfpepole",number_of_guest);
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }



        String Url="http://192.168.3.113/mywebservices.php?op=GetOrderCategory";
        GetNetworkData.OnPostExecuteListener listener=new GetNetworkData.OnPostExecuteListener() 
        {

            @Override
            public void onPostExecute(String result) {
                // TODO Auto-generated method stub
                if (result!=null)
                {
                    try
                    {
                     catItemsList.clear();
                 JSONArray jArray = new JSONArray(result);
                 ArrayList<ArrayList<HashMap<String, String>>> list=new ArrayList<ArrayList<HashMap<String, String>>>();
               //  ArrayList<Integer> category=new ArrayList<Integer>();

                 for (int i = 0; i < jArray.length(); i++) 

                    {
                      HashMap<String, String> Catmap = new HashMap<String, String>();

                        JSONObject e = jArray.getJSONObject(i);
                            id=e.getInt("order_id");

                         cat_name=e.getString("cat_name");
                          cat_id=e.getInt("cat_id");
                          Catmap.put("cat_id",String.valueOf(cat_id));
                          Catmap.put("cat_name", cat_name);
                          catItemsList.add(Catmap);
                          Log.i("Insid For Loop", "order ID "+order_id);

                          list=  BindCatItems(cat_id, order_id);
                        Log.i("Insid For Loop", "Child size = "+list.size());
                    }
               // Log.i("Insid For Loop", "Group size = "+catItemsList.size());


                 SimpleExpandableListAdapter expandListAdapter= new SimpleExpandableListAdapter(getActivity(), 
                         catItemsList,  R.layout.group_item, 
                          new String[] {"cat_name"},new int[]{R.id.lbl_cat_group},
                           list, R.layout.category_row, new String[]{"item_name"}, new int[]{R.id.txt_category_row});


                 order_items_list.setAdapter(expandListAdapter);
                      //  Log.i("Bind item", "CAT SIZE "+catItemsList.size());

                        }
                    catch(Exception e)
                    {
                        e.printStackTrace();
                    }
                }

            }

        };

        try
        {
        GetNetworkData task = new GetNetworkData(Url,params,listener);
        task.execute();
        }
        catch(Exception e)
        {

            e.printStackTrace();

        }
    }

    protected ArrayList<ArrayList<HashMap<String, String>>> BindCatItems(int cat_id,int order_id)

    {
        // TODO Auto-generated method stub

        JSONObject params = new JSONObject();
        //int    no_pepole=Integer.valueOf(noOfGest_txt.getText().toString());
            try
            {
        //  params.put("order_status",myStatus);
         int rest_id=prefs.getInt("Rest_id", 0);
            params.put("order_id", order_id);
            params.put("lang_id", 1);
            params.put("cat_id",cat_id );
            //params.put("order_status", 0);
        //  params.put("noOfpepole",number_of_guest);
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }


        String Url="http://192.168.3.113/mywebservices.php?op=GetOrderItems";
        GetNetworkData.OnPostExecuteListener listener=new GetNetworkData.OnPostExecuteListener() 

        {

            @Override
            public void onPostExecute(String result) {
                // TODO Auto-generated method stub
                if (result!=null)
                {
                    try
                    {
                        Log.i("log bind","Inside Bind Category items");
                        // catItemsList.clear();
                        mapList.clear();
                        JSONArray jArray = new JSONArray(result);

                            for (int i = 0; i < jArray.length(); i++) 
                            {
                                HashMap<String, String> map = new HashMap<String, String>();
                                JSONObject e = jArray.getJSONObject(i);

                                int id=e.getInt("item_id");
                                if (id==0)
                                {

                                }


                                else
                                {

                                map.put("item_id",String.valueOf(e.getInt("item_id")));
                                map.put("oi_id", String.valueOf(e.getInt("oi_id")));
                                map.put("item_name", e.getString("item_name"));
                                map.put("quantity",String.valueOf( e.getString("quantity")));
                                map.put("price", String.valueOf("price"));
                       mapList.add(map);

                                }
                            }
                            ItemsList.add(mapList);
                         //   Log.i("Bind Item Order", "CAT SIZE "+catItemsList.size());



                           /*  ItemsAdapter=new SimpleAdapter(getActivity(), catItemsList, 
                                    R.layout.list_item,
                                    new String[] {"item_name"},
                                    new int[]{R.id.list_item_title});
                           */
                           //  Log.i("Add Section","ItemsAdapter count= "+ItemsAdapter.getCount());


                             //order_list.setAdapter(adapter);
                            //adapter.notifyDataSetChanged();
                    }
                    catch(Exception e)
                    {
                        e.printStackTrace();
                    }
                }
            }
        };

        try
        {
        GetNetworkData task = new GetNetworkData(Url,params,listener);
        task.execute();
        }
        catch(Exception e)
        {

            e.printStackTrace();

        }
        return ItemsList;


    }
  • 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-03T10:16:18+00:00Added an answer on June 3, 2026 at 10:16 am

    According to documentation, SimpleExpandableListAdapter is for static data. What is happening here is probably that your methods are returning before the data is fetched and the listener passed to the AsyncTask is called after the adapter has already been created.

    So, the first thing I’d recommend to try is fetch the data first, and once the two listeners are executed ( by checking your own defined boolean flags or lists’ lengths ), define the adapter and pass it to the ListView.

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

Sidebar

Related Questions

Update1: this is all looks great but there is big problem which i have
I have a big problem. I want to extract text from html table that
I have an big problem with an SQL Statement in Oracle. I want to
I have a big problem using highcharts, because I have been trying for hours
I've been searching around for this, I've managed to find out out to change
I have a very big problem and can't seem to find anybody else on
This has been asked before and people have given very good instructions on how
Good day, Stackoverflow! I have a little (big) problem with porting one of my
I have big problem when I am trying to deploy my app over clickonce.
I have a (big) problem that all of you that work with Webforms might

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.