I'm trying to create a ListView that will consist of two types of elements: Strings and a GridView.
I.e. putting both Strings and a GridView inside one single ListView.
The layout should look something like this:
Is there any way to do this?
As per now I can only show the first item in the GridView, and it acts just as a regular String element in the ListView.
The code can be viewed here:
Any help is appreciated :)
To answer my own question:
Based on this answer I created this class that works very well:
public class NonScrollableGridView extends GridView {
public NonScrollableGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Do not use the highest two bits of Integer.MAX_VALUE because they are
// reserved for the MeasureSpec mode
int heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightSpec);
getLayoutParams().height = getMeasuredHeight();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With