Add a GridView to a ListView in Android

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:

  • 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 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 :)

Answers


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

Need Your Help

TypeError: $ is not a function when calling jQuery function

jquery wordpress function wrapper typeerror

I have a simple jQuery script in a WordPress plugin that is using a jQuery wrapper like this:

How to affect Delphi XEx code generation for Android/ARM targets?

android delphi android-ndk arm llvm

Update 2017-05-17. I no longer work for the company where this question originated, and do not have access to Delphi XEx. While I was there, the problem was solved by migrating to mixed FPC+GCC (Pa...