Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何显示包含动态更新的父级和子级的可扩展ListView?_Android_Listview_Expandablelistview_Expandablelistadapter - Fatal编程技术网

Android 如何显示包含动态更新的父级和子级的可扩展ListView?

Android 如何显示包含动态更新的父级和子级的可扩展ListView?,android,listview,expandablelistview,expandablelistadapter,Android,Listview,Expandablelistview,Expandablelistadapter,我想显示可扩展的listview,其中包含父项和子项,甚至子项。 这些数据将从服务器访问。数据可以作为JSON数据返回 我想访问与该父项关联的父项和子项。child也可能有子child Ex: Name Parent Level categoryId Audio 0 1 101 Video 0 1 102 songs

我想显示可扩展的listview,其中包含父项和子项,甚至子项。 这些数据将从服务器访问。数据可以作为JSON数据返回

我想访问与该父项关联的父项和子项。child也可能有子child

 Ex:
  Name       Parent        Level       categoryId
  Audio       0               1           101
  Video       0               1           102
  songs      101              2           201
  data       101              2           202
  myhost     201              3           301
  HD         102              2           401
  TV         401              3           500
上面的示例显示了现在可用的数据

附上我的密码

try {
    res1= httpclient1.execute(httppost1);
    responseBodys1 =EntityUtils.toString(res1.getEntity());

    JSONObject jsObject = new JSONObject(responseBodys1);
    JSONArray demo= jsObject.getJSONArray("categories");

    System.out.println("demo=="+demo.length());
    ArrayList<String> map = new ArrayList<String>();
    childs.add(new ArrayList<ArrayList<String>>());
    ArrayList<Integer> map1 = new ArrayList<Integer>();
    ArrayList<Integer> map3 = new ArrayList<Integer>();

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

    {
        JSONObject movie = demo.getJSONObject(i);
           ctName = movie.getString("ctName");
           ctParent= movie.getInt("ctParent");
           int ctLevel = movie.getInt("ctLevel");
           ctCategoryId=movie.getInt("ctCategoryId");
           map.add(ctName);
          map1.add(ctParent);
          // map1.add(ctLevel);
           map3.add(ctCategoryId);

          System.out.println("Map1-===>"+map);
           System.out.println("Map3-===>"+map3);

          if(ctParent==0)
          {
           groups.add(ctName);
          }

           if(ctParent!=0)
           {
             int ctP= movie.getInt("ctParent");
             System.out.println("ctp-->"+ctP);
             for(int j=0;j<demo.length();j++)
             {


             if(ctP==ctCategoryId)
             {
                 System.out.println("matched--"+ctP+"=="+ctCategoryId);
                childs.add(new ArrayList<ArrayList<String>>());
                childs.get(i).add(new ArrayList<String>());
                 childs.get(i).get(j).add(ctName);

             }

           }
           }
试试看{
res1=httpclient1.execute(httppost1);
responseBodys1=EntityUtils.toString(res1.getEntity());
JSONObject jsObject=新的JSONObject(responseBodys1);
JSONArray demo=jsObject.getJSONArray(“类别”);
System.out.println(“demo==”+demo.length());
ArrayList映射=新的ArrayList();
add(newarraylist());
ArrayList map1=新的ArrayList();
ArrayList map3=新的ArrayList();

对于(int i=0;iYou)而言,如果不编写自己的列表代码,您将无法拥有三个级别。Android股票可扩展列表仅用于组和子列表。如果不编写自己的列表代码,您将无法拥有三个级别。Android股票可扩展列表仅用于组和子列表。