bgogetap / StickyHeaders

Easily add Sticky Headers to your RecyclerView
Apache License 2.0
521 stars 88 forks source link

Update sticky header #71

Closed afbarbag closed 6 years ago

afbarbag commented 6 years ago

I'm trying to use a TabLayout where the TabLayout is a sticky header. There is no associated ViewPager. Upon clicking a tab, the items in the Adapter are changed and then notifyItemRangeChanged(tablayoutPosition, listSize) is called. The TabLayout view never reflects the updated selected tab when the view is being "stuck". But if the RecyclerView is scrolled such that the TabLayout is in it's natural position, the expected tab appears selected.

Is there any way to get the StickyHeader to have an updated view?

bgogetap commented 6 years ago

onBindViewHolder will not get called for stickied items, unfortunately.

You'll have to manage the state of that view in some other object that both view holders ("real" and stickied) can listen to.

bgogetap commented 6 years ago

Next release will have a way to get a reference to the view holder used for the sticky header, but I still suggest finding a different way to keep the view updated as juggling keeping the stickied view holder (if active) updated along with the normal list might be error prone.

afbarbag commented 6 years ago

Is there any way to access the view other than through the view holder?

bgogetap commented 6 years ago

You can use StickyHeaderListener