-1
嗨,我有一个XML解析example.here我必须添加可扩展listview.how是添加here.please帮助我。xml分析与可扩展的细节
这是我的代码:
public class SingleMenuItemActivity extends ExpandableListActivity {
static final String KEY_ARTIST = "payment_method";
static final String KEY_SUBTOTAL = "subtotal";
static final String KEY_DISCOUNT = "discount";
@SuppressWarnings("unchecked")
public void onCreate(Bundle savedInstanceState) {
try{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent in = getIntent();
String subtotal = in.getStringExtra(KEY_SUBTOTAL);
String discount = in.getStringExtra(KEY_DISCOUNT);
String payment_method = in.getStringExtra(KEY_ARTIST);
TextView lblSub = (TextView) findViewById(R.id.subtotal_label);
TextView lblTotal = (TextView) findViewById(R.id.total_label);
TextView lblPayment = (TextView) findViewById(R.id.payment_label);
lblSub.setText(subtotal);
lbldiscount.setText(discount);
lblPayment.setText(payment_method);
SimpleExpandableListAdapter expListAdapter =
new SimpleExpandableListAdapter(
this,
createGroupList(), // Creating group List.
R.layout.group_row, // Group item layout XML.
new String[] { "Order Info" }, // the key of group item.
new int[] { R.id.order},
// ID of each group item.-Data under the key goes into this TextView.
createChildList(), // childData describes second-level entries.
R.layout.single_list_item, // Layout for sub-level entries(second level).
new String[] {"payment_label:"}, // Keys in childData maps to display.
new int[] { R.id.payment_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 < 1 ; ++i) { // 15 groups........
HashMap m = new HashMap();
m.put("Order Info","Order Info " + i); // the key and it's value.
result.add(m);
}
return (List)result;
}
/* creatin the HashMap for the children */
@SuppressWarnings("unchecked")
private List createChildList() {
ArrayList result = new ArrayList();
for(int i = 0 ; i < 2 ; ++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();
child.put("payment_label", "payment_label " + n);
secList.add(child);
}
result.add(secList);
}
return result;
}
public void onContentChanged () {
System.out.println("onContentChanged");
super.onContentChanged();
}
/* This function is called on each child click */
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,int childPosition,long id) {
System.out.println("Inside onChildClick at groupPosition = " + groupPosition +" Child clicked at position " + childPosition);
return true;
}
/* This function is called on expansion of the group */
public void onGroupExpand (int groupPosition) {
try{
System.out.println("Group exapanding Listener => groupPosition = " + groupPosition);
}catch(Exception e){
System.out.println(" groupPosition Errrr +++ " + e.getMessage());
}
}
} 如果我必须点击特定的产品意味着它是进入下一活性。下一个活动都有详细的说明与扩张button.if我必须点击详细描述意味着它是扩展和显示payment_method,小计,折扣,否则它停留在less.please帮助我.how是要做.... ....如何开发我的代码与上述应用程序。
我main.xml中的文件是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ExpandableListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bkg"/>
<TextView android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No items"/>
这里我得到了输出为零......什么样的变化是我能做到here.please帮助我。
如果我必须点击详细的描述意味着它是扩大和显示标题,艺术家,持续时间,否则它是less.otherwise它留在less.please帮助我.HOW是做...我有从这个示例示例完成可扩展列表视图:http://www.coderzheaven.com/expandable-listview-android-simpleexpandablelistadapter-simple-example/...but如何在我的XML解析代码 – 2012-08-10 10:10:35