protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.activity_main); RecyclerView recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerview); this.updateButton = FindViewById <Button>(Resource.Id.button_update); this.isReverseButton = FindViewById <ToggleButton>(Resource.Id.button_is_reverse); // Set adapter populated with example dummy data this.adapter = new AnimalsHeadersAdapter(); adapter.Add("Animals below!"); adapter.AddAll(this.GetDummyDataSet()); recyclerView.SetAdapter(adapter); //adapter.RegisterAdapterDataObserver( // Set layout manager int orientation = this.GetLayoutManagerOrientation(this.Resources.Configuration.Orientation); this.layoutManager = new LinearLayoutManager(this, orientation, isReverseButton.Checked); recyclerView.SetLayoutManager(layoutManager); // Add the sticky headers decoration StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(adapter); recyclerView.AddItemDecoration(headersDecor); // Add decoration for dividers between list items recyclerView.AddItemDecoration(new DividerDecoration(this)); this.adapter.RegisterAdapterDataObserver(new HeaderAdapterObserver(headersDecor)); // Add touch listeners this.stickyTouchListener = new StickyRecyclerHeadersTouchListener(recyclerView, headersDecor); recyclerView.AddOnItemTouchListener(this.stickyTouchListener); this.recyclerItemClick = new RecyclerItemClickListener(this); recyclerView.AddOnItemTouchListener(recyclerItemClick); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.activity_main); RecyclerView recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerview); this.updateButton = FindViewById<Button>(Resource.Id.button_update); this.isReverseButton = FindViewById<ToggleButton>(Resource.Id.button_is_reverse); // Set adapter populated with example dummy data this.adapter = new AnimalsHeadersAdapter(); adapter.Add("Animals below!"); adapter.AddAll(this.GetDummyDataSet()); recyclerView.SetAdapter(adapter); //adapter.RegisterAdapterDataObserver( // Set layout manager int orientation = this.GetLayoutManagerOrientation(this.Resources.Configuration.Orientation); this.layoutManager = new LinearLayoutManager(this, orientation, isReverseButton.Checked); recyclerView.SetLayoutManager(layoutManager); // Add the sticky headers decoration StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(adapter); recyclerView.AddItemDecoration(headersDecor); // Add decoration for dividers between list items recyclerView.AddItemDecoration(new DividerDecoration(this)); this.adapter.RegisterAdapterDataObserver(new HeaderAdapterObserver(headersDecor)); // Add touch listeners this.stickyTouchListener = new StickyRecyclerHeadersTouchListener(recyclerView, headersDecor); recyclerView.AddOnItemTouchListener(this.stickyTouchListener); this.recyclerItemClick = new RecyclerItemClickListener(this); recyclerView.AddOnItemTouchListener(recyclerItemClick); }