StickyListHeaders icon indicating copy to clipboard operation
StickyListHeaders copied to clipboard

hide/show or enable/disable headers

Open sababado opened this issue 12 years ago • 8 comments

There should be a way to hide all headers and a way to show headers. Similar to setting visibility to VISIBLE and GONE.

sababado avatar Nov 20 '13 22:11 sababado

My Workaround:

    @Override
    public View getHeaderView(int position, View convertView, ViewGroup parent) {
        if (!mShowSections) {
            View v = new View(mContext);
            v.setVisibility(View.GONE);
            return v;
        }
        ...
    }

...

    @Override
    public long getHeaderId(int position) {
        if (!mShowSections) {
            return 0;
        }
        return ...;
    }

cmaier avatar Jan 16 '14 10:01 cmaier

There used to be a pull request which let you easily do this by returning null in the header methods, but it was rejected.

https://github.com/emilsjolander/StickyListHeaders/pull/163 allow to suppress grouping by returning null from getHeaderView

jenzz avatar Feb 27 '14 12:02 jenzz

@cmaier your adapter "hack" work, but there is little problem with this solution. The first header will take some space in the StickyListHeadersListView. The first divider will not be draw.

I hope this feature will be implemented.

public interface StickyListHeadersAdapter extends android.widget.ListAdapter { ... public boolean isHeaderShow(boolean isShown); ... }

CedrickFlocon avatar May 06 '14 08:05 CedrickFlocon

I encountered this issue as well in many projects actually. For example, we have a TransactionsListFragment which uses a StickyListHeaderListView for grouping multiple transactions under the same day. But in some areas of our app we need the same fragment without the day grouping. So a simple isHeaderShow(boolean) like Neige wrote above would be more than perfect. Hell, even the null hack pull request would still be a great addition rather than nothing. Until this issue is resolved, I have to also use another plain ListView inside the layout in order to achieve this... not cool man.... So, can you guys consider at least merging in the pull request, if not adding the aforementioned method ?

bogdanzurac avatar May 25 '14 10:05 bogdanzurac

It seems not so safe that returning null in getHeaderView method. May be we have any other way to implement the feature.

lsjwzh avatar Jul 25 '14 03:07 lsjwzh

There is possibility to hide all headings, for example depending on item count(10) , if you use this logic if(fullList.size()>9){ mListView.setAdapter(adapter); }else{ mListView.getWrappedList().setAdapter(adapter); // This is the main point } But the wrapper method has this description - Use the method with extreme caution!!... With this logic it is easy to control the headings and there are no problems with GONE view that takes space.

Mikelis avatar Nov 06 '14 17:11 Mikelis

So no intention to actually make this baked into the API ? It's been almost 1 and a half years since the initial request...

bogdanzurac avatar Apr 27 '15 08:04 bogdanzurac

+1 It'd be super beneficial.

patedit avatar Apr 13 '16 00:04 patedit