Results 1 to 2 of 2
  1. #1
    krishnaveni is offline Member
    Join Date
    Aug 2012
    Posts
    1
    Rep Power
    0

    Default 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.
    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;
        }
    Here my above code is not worked..so please help me i have to change what line.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,254
    Rep Power
    19

    Default Re: Create 2 groups in expandable listview

    Quote Originally Posted by krishnaveni View Post
    Hi i have try to develop expandable listview in android application.
    Moved from New to Java.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Activity's ListView items do not show
    By KernelPanic in forum Android
    Replies: 0
    Last Post: 05-17-2012, 07:21 AM
  2. Mather groups order
    By jammybell in forum New To Java
    Replies: 1
    Last Post: 04-08-2012, 06:52 PM
  3. ListView Sub Items
    By rolledback in forum Android
    Replies: 2
    Last Post: 09-21-2011, 09:21 PM
  4. listView and listArray methods
    By viviosoft in forum Android
    Replies: 0
    Last Post: 09-09-2011, 10:08 PM
  5. Expandable Grid Panel
    By Lee.J.Baxter in forum Advanced Java
    Replies: 2
    Last Post: 08-23-2009, 10:53 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •