android - RecyclerView header and footer -


Perhaps this question has been asked before, but I could not find an exact answer or solution. I started using Recycler Weave, and I implemented it using LinearLayoutManager. Now I want to add custom header and footer items, which are different from all other items in my recycling view. The header and footer should not be sticky, I want to scroll them with the remaining items. Can someone tell this example how to do it or just share ideas? I appreciate it very much Thx

Add this class to your adapter:

  Private class VIEW_TYPES {public static final interval header = 1; Public static final integer normal = 2; Public stable final interval Pitter = 3; }  

Then override the following method like this:

  @ Override public int iTamas view type (int position) {if (items.jet ( Status).) Return VIEW_TYPES.Header; Otherwise if (get item (condition). Super) return VIEW_TYPES.Footer; And return VIEW_TYPES. Normal; }  

Now increase your layout based on view type in Creativesholder method:

  @Override public viewfinder onCreateViewHolder (ViewGroup viewGroup, int i) {line View View; Switch (i) {Case VIEW_TYPES. Normal: rowView = LayoutInflator.from (viewGroup.getContext ()). Flowers (R. layout. Normal, visual group, wrong); break; Case VIEW_TYPES.Header: rowView = LayoutInflator.fr (viewGroup.getContext ()). Flowers (R. layout. Title, view group, wrong); break; Case VIEW_TYPES.Footer: rowView = LayoutInflater.from (viewGroup.getContext ()) Flight (R. layout. Power, view group, incorrect); break; Default: rowView = LayoutInflator.fr (view group tag) (). Flowers (R. Lait. Normal, Visual group, False); break; } Return new viewholder (lineview); }  

Hope this can help.


Comments