本文介绍了在Android的可扩展列表视图创建2组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我有我的列表视图扩展的Android打造2组application..but我不能开发this.please帮助我。
这是我的code:
Hi i have to create 2 groups in my expandable listview android application..but i can't develop this.please help me.this is my code:
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;
}
在这里,我要创建2组订单信息和customerinfo..how是创造高于code..please帮助我。
here i have to create 2 groups orderinfo and customerinfo..how is create above code..please help me.
推荐答案
我觉得这是创建可扩展列表视图的正确方法
。但可能会有一些问题。所以只是去通过这个。
I think this is the correct way of creating Expandable List View
.But there may be something problem. so just go through this link.
请检查您必须 ExpandableListActivity
和
在布局给ID为机器人:ID =@ + ID /安卓名单
为 ExpandableListView
这篇关于在Android的可扩展列表视图创建2组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!