Results 1 to 2 of 2
- 08-14-2012, 07:52 AM #1
Member
- Join Date
- Aug 2012
- Posts
- 1
- Rep Power
- 0
Create 2 groups in expandable listview
Hi i have try to develop expandable listview in android application.now i have one doubts.how is creating 2 groups ion below my code for separate child details...For Eg:
Group name:
OrderInfo,CustomerInfo.
Childname(OrderInfo)ayment_method.
Childname(CustomerInfo):name,email.How is to do.Please help me.
Here my above code is not worked..so please help me i have to change what line.Java 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 < 1 ; ++i ) { // 15 groups........ HashMap m = new HashMap(); // m.put( "OrderInfo","CustomerInfo"); // the key and it's value. m.put( "OrderInfo", OrderInfo); 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 < 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(); Intent in = getIntent(); String payment_method = in.getStringExtra(KEY_ARTIST); TextView lblPayment = (TextView) findViewById(R.id.payment_label); /// lblPayment.setText(payment_method); int payment; payment=1; String s= getIntent().getStringExtra("payment_method"); String s1= getIntent().getStringExtra("total"); String s2= getIntent().getStringExtra("subtotal"); String s3= getIntent().getStringExtra("discount"); String s4= getIntent().getStringExtra("coupon_discount"); String s5= getIntent().getStringExtra("shipping_cost"); child.put( "KEY_ARTIST", s); child.put( "KEY_DURATION", s1); child.put( "KEY_SUBTOTAL", s2); child.put( "KEY_DISCOUNT", s3); child.put( "KEY_COUPON", s4); child.put( "KEY_COST", s5); secList.add( child); } result.add( secList ); } return result; }
- 08-14-2012, 09:44 AM #2
Similar Threads
-
Activity's ListView items do not show
By KernelPanic in forum AndroidReplies: 0Last Post: 05-17-2012, 07:21 AM -
Mather groups order
By jammybell in forum New To JavaReplies: 1Last Post: 04-08-2012, 06:52 PM -
ListView Sub Items
By rolledback in forum AndroidReplies: 2Last Post: 09-21-2011, 09:21 PM -
listView and listArray methods
By viviosoft in forum AndroidReplies: 0Last Post: 09-09-2011, 10:08 PM -
Expandable Grid Panel
By Lee.J.Baxter in forum Advanced JavaReplies: 2Last Post: 08-23-2009, 10:53 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks