Tuesday, August 14, 2012

Re: [android-developers] Create 2 groups in expandable listview

If you want to get help, you might consider reading this, and then asking a more clearly defined question:
http://android-dev-tips-and-tricks.blogspot.com/2012/08/so-you-need-help.html

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Tue, Aug 14, 2012 at 12:26 AM, Krishna Veni <mercy.krishnaveni@gmail.com> wrote:

Hi I have tried 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 to do 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","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.

               

                );

            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();

                   map.put( "CustomerInfo","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.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment