-1

我必须使用下面的代码...我必须为第一组获取子值...但是在这里我必须单击第二组意味着它没有展开并且同时应用程序被强制关闭。所以请帮助我..怎么样为不同的父母设置不同的孩子价值......请给我这个示例代码......

private List createGroupList() {

    Log.d(TAG, "Adding groups values");
    List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
    HashMap<String, String> statusMap = new HashMap<String, String>();
    statusMap.put(GroupID, "OrderInfo");
    list.add(statusMap);
    HashMap<String, String> usersMap = new HashMap<String, String>();
    usersMap.put(GroupID, "CustomerInfo");
    list.add(usersMap);
    Log.d(TAG, "Adding groups values successfull");
    return list;
}


 private List createChildList() {

    ArrayList result = new ArrayList();
    for( int i = 0 ; i < 1 ; ++i ) { // this -15 is the number of groups(Here it's fifteen)
      /* each group need each HashMap-Here for each group we have 3 subgroups */
      ArrayList secList = new ArrayList();
      for( int n = 0 ; n < 1 ; n++ ) {
        HashMap child = new HashMap();


       String s= getIntent().getStringExtra("payment_method");
       String s1= getIntent().getStringExtra("total");
       String s2= getIntent().getStringExtra("firstname");
       String s3= getIntent().getStringExtra("lastname");

     child.put( "KEY_ARTIST", s);
     child.put( "KEY_DURATION", s1);
     child.put( "KEY_FNAME", s2);
     child.put( "KEY_LNAME", s3);

        secList.add( child);
      }
     result.add( secList );
    }
    return result;
}
4

1 回答 1

0

使用此代码:

final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final ArrayList<HashMap<String, String>> headerData = new ArrayList<HashMap<String, String>>();

    final HashMap<String, String> group1 = new HashMap<String, String>();
    group1.put(NAME, "OrderInfo");
    headerData.add( group1 );

    final HashMap<String, String> group2 = new HashMap<String, String>();
    group2.put(NAME, "CustomerInfo");
    headerData.add( group2);

    final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>();

    final ArrayList<HashMap<String, Object>> group1data = new ArrayList<HashMap<String, Object>>();
    childData.add(group1data);

    final ArrayList<HashMap<String, Object>> group2data = new ArrayList<HashMap<String, Object>>();
    childData.add(group2data);

上面的代码对我有用....所以试试上面的代码。

于 2012-08-21T04:18:31.663 回答