Create 2 groups in android expandable listview


  1. krishnaveni

    krishnaveni Well-Known Member

    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):payment_method.
    Childname(CustomerInfo):name,email.How is to do.Please help me.

    My code is:
    Code (Text):
    1.  
    2.  SimpleExpandableListAdapter expListAdapter =
    3.             new SimpleExpandableListAdapter(
    4.                     this,
    5.                    
    6.                     createGroupList(),              // Creating group List.
    7.                     R.layout.group_row,  
    8.                   // Group item layout XML.
    9.                     new String[] { "OrderInfo","CustomerInfo"},  // the key of group item.
    10.                     new int[] { R.id.order,R.id.customer},
    11.                    
    12.                     // ID of each group item.-Data under the key goes into this TextView.
    13.                     createChildList(),              // childData describes second-level entries.
    14.                     R.layout.single_list_item,  
    15.                   //  new String[] {"KEY_ARTIST"},  
    16.                    // new int[] { R.id.payment_label}  // Keys in childData maps to display.
    17.                       // Layout for sub-level entries(second level).
    18.                    new String[] {"KEY_ARTIST","KEY_DURATION","KEY_SUBTOTAL","KEY_DISCOUNT","KEY_COUPON","KEY_COST"},  
    19.                    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.
    20.                  //   new int[] { R.id.payment_label,R.id.total_label}     // Data under the keys above go into these TextViews.
    21.                 );
    22.             setListAdapter( expListAdapter );       // setting the adapter in the list.
    23.  
    24.         }catch(Exception e){
    25.             System.out.println("Errrr +++ " + e.getMessage());
    26.         }
    27.     }
    28.    
    29.     /* Creating the Hashmap for the row */
    30.     @SuppressWarnings("unchecked")
    31.     private List createGroupList() {
    32.           ArrayList result = new ArrayList();
    33.           for( int i = 0 ; i < 1 ; ++i ) { // 15 groups........
    34.             HashMap m = new HashMap();
    35.            m.put( "CustomerInfo","CustomerInfo"); // the key and it's value.
    36.            m.put( "OrderInfo", OrderInfo);
    37.          
    38.             result.add( m );
    39.           }
    40.           return (List)result;
    41.          
    42.     }
    Here my above code is not worked..so please help me i have to change what line.

    Advertisement
    :
Loading...

Share This Page