How to disable or not show headers for StickyListHeaders by emilsjolander

I use https://github.com/emilsjolander/StickyListHeaders as the main list for most of my applications. I put this list in my layout, which I use for all of my lists. However, there are some cases when I do not want to show any headers, I just want to show a normal list, for example listview.

Is there a way to set so that StickyListHeaders do not display headers at all? There are options to ensure that the headlines are not sticky. I want the headers to simply not display, is this possible using the existing API?

@Override public View getHeaderView(int position, View convertView, ViewGroup parent) { // do nothing return null; } @Override public long getHeaderId(int position) { // do nothing return 0; } 
+4
source share
4 answers

There is actually a much simpler way

 @Override public View getHeaderView(int position, View convertView, ViewGroup parent) { return new View(parent.getContext()); } 
+5
source

I had the same requirement and managed to install the StickyListHeaders fix to behave like a normal list when getHeaderView returns null. So far, I have not yet encountered the side effects of this change: https://github.com/mtotschnig/StickyListHeaders/commit/9252a6fe5367bc2421739bb5d34856343236dd24

+2
source

Try disabling the sticky list header:

  @Override public View getHeaderView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; holder = new HeaderViewHolder(); convertView = inflater.inflate(R.layout.header, parent, false); holder.text1 = (TextView) convertView.findViewById(R.id.text1); convertView.setTag(holder); convertView.setVisibility(View.VISIBLE); String headerText = ""; } else if (position > mainList.size() - 1) { headerText = "Categories"; } else { headerText = ""; return new View(getActivity()); } holder.text1.setText(headerText); return convertView; } 
+1
source

I also had this requirement recently, and eventually I fixed version 2.3.0 of the library to allow null headers: https://github.com/xlsior/StickyListHeaders/tree/null-headers

0
source

Source: https://habr.com/ru/post/1491716/


All Articles