Java 在android的可扩展列表视图中创建2个组

Java 在android的可扩展列表视图中创建2个组,java,android,expandablelistview,Java,Android,Expandablelistview,嗨,我必须在我的可扩展的listview android应用程序中创建两个组。但是我不能开发这个。请帮助我。 这是我的代码: SimpleExpandableListAdapter expListAdapter = new SimpleExpandableListAdapter( this, createGroupList(), // Creating group List.

嗨,我必须在我的可扩展的listview android应用程序中创建两个组。但是我不能开发这个。请帮助我。 这是我的代码:

SimpleExpandableListAdapter expListAdapter =
        new SimpleExpandableListAdapter(
                this,
                createGroupList(),              // Creating group List.
                R.layout.group_row,             // Group item layout XML.
                new String[] { "OrderInfo","CustomerInfo"},  // the key of group item.
                new int[] { R.id.order,R.id.customer},

                // ID of each group item.-Data under the key goes into this TextView.
                createChildList(),              // childData describes second-level entries.
                R.layout.single_list_item,  
              //  new String[] {"KEY_ARTIST"},  
               // new int[] { R.id.payment_label}  // Keys in childData maps to display.
                  // Layout for sub-level entries(second level).
               new String[] {"KEY_ARTIST","KEY_DURATION","KEY_SUBTOTAL","KEY_DISCOUNT","KEY_COUPON","KEY_COST"},  
               new int[] { R.id.payment_label,R.id.total_label,R.id.discount_label,R.id.discount_label,R.id.coupon_label,R.id.cost_label}// Keys in childData maps to display.
             //   new int[] { R.id.payment_label,R.id.total_label}     // Data under the keys above go into these TextViews.
            );
        setListAdapter( expListAdapter );       // setting the adapter in the list.

    }catch(Exception e){
        System.out.println("Errrr +++ " + e.getMessage());
    }
}

/* Creating the Hashmap for the row */
@SuppressWarnings("unchecked")
private List createGroupList() {
      ArrayList result = new ArrayList();
      for( int i = 0 ; i < 2 ; ++i ) { // 15 groups........
        HashMap m = new HashMap();
       m.put( "OrderInfo","CustomerInfo " + i ); // the key and it's value.


        result.add( m );
      }
      return (List)result;

}
SimpleExpandableListAdapter解释适配器=
新的SimpleExpandableListAdapter(
这
createGroupList(),//正在创建组列表。
R.layout.group_行,//组项布局XML。
新字符串[]{“OrderInfo”,“CustomerInfo”},//组项的键。
新int[]{R.id.order,R.id.customer},
//每个组项的ID。-键下的数据进入此文本视图。
createChildList(),//childData描述二级条目。
R.布局。单个列表项,
//新字符串[]{“KEY_ARTIST”},
//要显示的childData映射中的新int[]{R.id.payment_label}//键。
//子级条目的布局(第二级)。
新字符串[]{“关键艺术家”、“关键持续时间”、“关键小计”、“关键折扣”、“关键优惠券”、“关键成本”},
要显示的子数据映射中的新int[]{R.id.payment\u标签、R.id.total\u标签、R.id.discount\u标签、R.id.discount\u标签、R.id.cost\u标签}//键。
//新的int[]{R.id.payment_label,R.id.total_label}//以上键下的数据进入这些文本视图。
);
setListAdapter(expListAdapter);//在列表中设置适配器。
}捕获(例外e){
System.out.println(“Errrr++”+e.getMessage());
}
}
/*为行创建Hashmap*/
@抑制警告(“未选中”)
私有列表createGroupList(){
ArrayList结果=新建ArrayList();
对于(int i=0;i<2;++i){//15组。。。。。。。。
HashMap m=新的HashMap();
m、 put(“OrderInfo”、“CustomerInfo”+i);//键及其值。
结果:添加(m);
}
返回(列表)结果;
}

这里我必须创建两组orderinfo和customerinfo。如何创建上面的代码。请帮助我。

我认为这是创建
可扩展列表视图的正确方法。
。但可能存在一些问题。所以,就这样做吧

请检查您是否必须通过
ExpandableListActivity

在布局中为
android:id=“@+id/android:list”
for
ExpandableListView