Saturday, 24 August 2013

Android ExpandableListView with GridView

Step are: 1
Crete 3 xml file  a) list_items_column.xml

android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="@+id/rl_row_layout_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tv_heading"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:background="#E5EAF5"
android:gravity="center_vertical"
android:textStyle="bold" >

b) Expandable child is row_grid.xml


android:id="@+id/gridView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:columnWidth="80dp"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >

3.Now the Last xml is grid childern.xml

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp" >
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"
android:layout_marginTop="15sp"
android:textSize="15sp" >


2 Step... In expandable list Adapter get Child View U can add following code.....
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item_grid_row, null);
}
GridView label = (GridView) convertView.findViewById(R.id.gridView);
int totalHeight=0;
for (int size = 0; size < adapter.getCount(); size++) {
RelativeLayout relativeLayout = (RelativeLayout) adapter.getView(size, null,
label);
TextView textView = (TextView) relativeLayout.getChildAt(0);
textView.measure(0, 0);
totalHeight += textView.getMeasuredHeight();
}
ViewGroup.LayoutParams params = (ViewGroup.LayoutParams)label.getLayoutParams();
if (params != null)
{
params.height = totalHeight;
}
return convertView;
}



41 comments:

  1. Can u post me the full source code.

    ReplyDelete
  2. can u post me the full source code :D
    my email id is littlemush@naver.com
    Thank you !

    ReplyDelete
  3. Hello Akash Shah,
    Would you please post me this source code to my mail hichemlaroussi@gmail.com
    Thx in advance :)

    ReplyDelete
  4. can u post me the full source code :D
    my email id is pal.soman77@gmail.com
    Thank you !

    ReplyDelete
  5. can u post me the full source code :
    my email id is sugneshlimbasiya@gmail.com
    Thank you !

    ReplyDelete
  6. Sunday I will Send mail to all of You....Thanks Akash

    ReplyDelete
  7. Hi can i get a copy of your source code also? Thanks
    ang_shaun@hotmail.com

    ReplyDelete
  8. best tutorial . Can you give full source code ? Thanks .
    khangcntt.it92@gmail.com

    ReplyDelete
  9. hello, can you please send me your source code? patoevoix@gmail.com
    thank you

    ReplyDelete
  10. Hi Akash Shah,
    this is very good tutorial, kindly if you share the source code so everyone can learn more from your best blog.
    Thanks.

    ReplyDelete
  11. Hello Sir... please provide me also the source code my id is jyoti.minhas8@gmail.com

    ReplyDelete
  12. please can you post me the full source code?
    microgomi@gmail.com

    ReplyDelete
  13. please can you mail me the source code

    devrath.dev595@hotmail.com

    ReplyDelete
  14. can I see your source code?
    I need this.
    thank you for your appreciation

    yeasolkim94@gmail.com

    ReplyDelete
  15. Hi, Can you please send the code to ashwanikumar04@gmail.com

    ReplyDelete
  16. Hi, could yoy send the source code to christian.olivier8@gmail.com ? tnx

    ReplyDelete
  17. i, could you send the source code to sagilorber8@gmail.com ? tnx

    ReplyDelete
  18. Akash Shahさん。
    ソース・コードをおねがいします。
    ohdonghoon21@gmail.com

    ReplyDelete
  19. please share to full source code in my mail id cap.ujjawal@gmail.com

    ReplyDelete
  20. hi, could you please share the code to immorality_boy [et] yahoo [dot] com

    ReplyDelete
    Replies
    1. https://github.com/coolwd10/ExpandablelistwithGirdview

      Delete
  21. please share the source code or post it on this webpage. It would be very helpful.

    asit_monty@yahoo.co.in

    ReplyDelete
    Replies
    1. https://github.com/coolwd10/ExpandablelistwithGirdview

      Delete
  22. please send me the full source code....

    ReplyDelete
    Replies
    1. https://github.com/coolwd10/ExpandablelistwithGirdview

      Delete
  23. Hi All i added all file below link... U create ExpandablelistwithGirdview project in androd and add this file.

    https://github.com/coolwd10/ExpandablelistwithGirdview

    ReplyDelete
  24. Can u post me the full source code.

    ReplyDelete
    Replies
    1. And my id is shekharsrivastava111@gmail.com

      Delete
  25. Can u post me the full source code.

    ReplyDelete
  26. This comment has been removed by the author.

    ReplyDelete
  27. Can you post me the full source code.

    vishalgadhiya91@gmail.com

    ReplyDelete
  28. I have tryed the code at github, but the application stops every time I try to expand a group :/

    ReplyDelete
  29. this code adds scroll to every child grid view. How to ovoid it?

    ReplyDelete
  30. Hello Akash Shah,
    can you give me the full source of code in my email id apoorv.bam@gmail.com

    ReplyDelete
  31. Hello Sir,
    Can u mail me the entire code
    akswadkar35153515@gmail.com

    ReplyDelete
  32. Hello Sir,
    Can u mail me the entire code
    mdmanzil@gmail.com

    ReplyDelete
  33. Hello
    Please can you send all code on my mail kvinodchand@gmail.com

    ReplyDelete
  34. hai can you send me the full source code mail id : saikumarbadapatla@gmail.com

    ReplyDelete