views:

58

answers:

1

I'm trying to create a ListView that will consist of to 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:

Code list (Since I only can post one link)

Any help is appreciated :)

+1  A: 

I'm trying to create a ListView that will consist of to types of elements: Strings and a GridView.

That is unlikely to work. You cannot put things that know how to scroll (e.g., GridView) in a ListView.

CommonsWare
Isn't it possible to set the `GridView` not to scroll and always show the full `height`? Any other solutions to my problem is also appreciated :)
greve
Another solution could be to use a only a GridView, but make it have varying nr. of columns for each row such that one row only had one column, while others have more. Any idea on how to do that?
greve
@greve: "Isn't it possible to set the GridView not to scroll and always show the full height?" -- the problem is that it will steal touch events from the `ListView`, thinking that vertical swipes are meant for the `GridView`. "but make it have varying nr. of columns for each row" -- that is not possible with `GridView`.
CommonsWare
I think I found a very custom solution. Creating my own custom `ScrollView` that has a `TableLayout` as a child view with methods to `addList(List<String> list)` and `addGrid(List<String> list, int columnWidth, int horizontalSpacing, int verticalSpacing)` which creates `TableRow` s in the appropriate sizes
greve