1

I need a sectioned gridView like the one in gallery app in samsung gallaxy s5 android verion 5.0. Where I can select multiple pictures and send them the the next activity.

Any help will be appreciated. Thanks.

enter image description here

Ali
  • 141
  • 3
  • 12

2 Answers2

1

You can use this class to realize a simple sectioned grid RecyclerView.Adapter without changing your code using this library.
SectionedGridRecyclerViewAdapter by gabrielemariotti

enter image description here

Kartheek
  • 7,104
  • 3
  • 30
  • 44
-2

I would dynamically create a vertical list of elements in code:

  • group header

  • grid view with 3 images

  • grid view with 3 images

  • group header

  • grid view with 3 images

  • ....

Not everything can be done in xml :)

See here how to create grid view: How to create GridView image gallery programmatically in android?

Community
  • 1
  • 1
FDIM
  • 1,981
  • 19
  • 21
  • 1
    ... and forfeit view recycling which is even more important when dealing with images. – Eugen Pechanec May 27 '15 at 09:57
  • Depends on implementation. If you make a list view with customized view(which would include header and grid, can be even defined in xml) - recycling would not be lost. – FDIM May 27 '15 at 10:43
  • In that fashion the best you could do (and about the only thing you should do) would be having a separate gridview for each line. Because every listview child is loaded fully as it comes into view. So if you have a gridview of 1000 images inside a listview, the whole gridview will be loaded even if you see only a portion of it. – Eugen Pechanec May 27 '15 at 10:49
  • True, that changes logic a bit. You would have to create custom header view and custom grid view for each "row". And figure out which one is right to inflate when view is about to be shown to the user - which will probably be a little tricky to figure out. – FDIM May 27 '15 at 10:53
  • 1
    [View types](http://stackoverflow.com/questions/4777272/android-listview-with-different-layout-for-each-row) ;) – Eugen Pechanec May 27 '15 at 10:55
  • 1
    And while we're arguing about this RecyclerView + GridLayoutManager + SpanSizeLookup can already do everything OP needs :D – Eugen Pechanec May 27 '15 at 10:57