I want to implement the sticky gridview
in my application but the problem is that my header of the gridview
is also move when I scroll the gridview
, So could you please help me to sort out from these problem

- 7,846
- 14
- 53
- 103
-
Any demo application about the sticky gridview will also be helpful thanks :) β Ravindra Kushwaha Oct 10 '14 at 05:02
-
Check out my answer it might help you. β GrIsHu Oct 10 '14 at 06:49
2 Answers
You can check out StickyGridHeaders
is library that provides a GridView
that shows items in sections with headers. By default the section headers stick to the top like the People app in Android 4.x but this can be turned off.
StickyGridHeaders also automatically sizes its rows to the largest item in the row.
Another is AStickyHeader for adding Sticky Headers to ListView or GridView.
Hope this will help you.

- 29,068
- 10
- 64
- 102
TonicArtos's repo is great, but I found it hard to integrate it with my app. Also, I couldn't get the example code to run so I decided to fork it and improve it a little bit.
The only thing that was added was 2 classes that makes the creation of the adapter a lot easier IMO.
The first of those classes is:
public abstract class UtilAdapter<T, VH extends BaseViewHolder> extends BaseAdapter {
//methods to add and remove elements & viewholder implementation
}
This class provides some methods to add and remove elements from an internal list it has (kind of what ArrayAdapter does). It also implements the viewholder pattern for you so you just have to implement a few abstract methods.
The second class is:
public abstract class StickyGridAdapter<T, VH extends BaseViewHolder, HVH extends BaseViewHolder> extends UtilAdapter<T, VH> implements StickyGridHeadersSimpleAdapter {
//viewholder imlpementation for the header view (also has abstract methods)
}
This class implements StickyGridHeadersSimpleAdapter (TonicArtos's interface). It also implements the viewholder pattern for the header views, so extending this class makes you implement a few methods that return ViewHolder classes and other methods that populate said viewholders.
To implement a sticky header grid you just have to extend StickyGridAdapter, use StickyGridHeadersGridView instead of GridView in your layout and set the adapter as usual.
Here is a link to the repo (which is a fork of TonicArto's):
https://github.com/OneCodeLabs/StickyGridHeaders
I also wrote some example code using my classes. I hope it can help you

- 41
- 3
-
1Welcome to Stack Overflow! A link to a potential solution is always welcome, but please [add context around the link](http://meta.stackoverflow.com/a/8259/169503) so your fellow users will have some idea what it is and why itβs there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. Take into account that being _barely more than a link to an external site_ is a possible reason as to [Why and how are some answers deleted?](http://stackoverflow.com/help/deleted-answers). β Rizier123 Mar 06 '16 at 10:34