Add a GridView to a ListView in Android -
i'm trying create listview consist of 2 types of elements: strings , gridview.
i.e. putting both strings , gridview inside 1 single listview.
the layout should this:
- string item 1.1
- string item 1.2
- string item 1.3
- string item 1.4
- gridview item 1 gridview item 2
gridview item 3 gridview item 4 - string item 2.1
- string item 2.2
- string item 2.3
- string item 2.4
is there way this?
as per can show first item in gridview, , acts regular string element in listview.
the code can viewed here:
- customlistviewactivity.java
- sectionadapter.java
- main.xml
- header_row.xml
- simple_list_row.xml
- grid_list_row.xml
any appreciated :)
to answer own question:
based on this answer created class works well:
public class nonscrollablegridview extends gridview { public nonscrollablegridview(context context, attributeset attrs) { super(context, attrs); } @override protected void onmeasure(int widthmeasurespec, int heightmeasurespec) { // not use highest 2 bits of integer.max_value because // reserved measurespec mode int heightspec = measurespec.makemeasurespec(integer.max_value >> 2, measurespec.at_most); super.onmeasure(widthmeasurespec, heightspec); getlayoutparams().height = getmeasuredheight(); } }