6

I just started using recycler view but i can't seem to find any way to set header or footer to recycler view note that i'm using LinearLayouManager.

is there any way to add header to recycler view ?

SOLVED

i used this pattern https://stackoverflow.com/a/26573338/2127203

Community
  • 1
  • 1
EC84B4
  • 7,676
  • 4
  • 23
  • 34
  • a specific view at top for header and another view in the end of recycler view for footer. for example a loading view in footer – EC84B4 Oct 26 '14 at 06:10
  • so create an adapter that overrides `getItemViewType(int position)` method and return three different types: headerType for position == 0, viewType for position in [1..cnt-2] and footerType for position == cnt-1 – pskink Oct 26 '14 at 06:16
  • i need to access the instance of that view from outside of adapter wouldn't that instance change ? – EC84B4 Oct 26 '14 at 06:30
  • you cant do it: the RecyclerView can recycle them in any time, even if they are single views, if you want to change the header then change the data model and call one of Adapter.notify* methods – pskink Oct 26 '14 at 06:40
  • take a look at this http://stackoverflow.com/a/26573338/2127203 – EC84B4 Oct 28 '14 at 05:54
  • what is that link for? it overrides getItemViewType as i said above... – pskink Oct 28 '14 at 07:51

0 Answers0