/* Scroll up to the top of the page if the "Announcements" layout is */
 /* selected                                                          */
 private void TabReselected(object sender,
                            TabLayout.TabReselectedEventArgs e)
 {
     if (e.Tab.Text == "Announcements")
     {
         if (AnnouncementAdapter.ViewPosition >= 10)
         {
             AnnouncementRecyclerView.ScrollToPosition(10);
         }
         AnnouncementRecyclerView.SmoothScrollToPosition(0);
     }
 }
        public override View OnCreateView(LayoutInflater inflater,
                                          ViewGroup parent, Bundle savedInstanceState)
        {
            /* Inflate the layout for the fragment                           */
            AnnouncementsView = inflater.Inflate(
                Resource.Layout.AnnouncementsFragmentLayout, parent, false);

            /* Get the recyclerview layout                                   */
            AnnouncementRecyclerView =
                AnnouncementsView.FindViewById <RecyclerView>(
                    Resource.Id.AnnouncementsRecyclerView);

            /* Create a new layout manager using the activity containing     */
            /* this fragment as the context                                  */
            AnnouncementLayoutManager = new LinearLayoutManager(Activity);

            /* Create a custom adapter and pass it the data that it will be  */
            /* recycling through                                             */
            AnnouncementAdapter =
                new announcementsRecyclerViewAdapter(Activity as mainActivity, Announcements);

            /* Helps with performance: HasStableIds = true
             * ALTHOUGH FOR NOW, DO NOT INCLUDE THIS: DATA DOES NOT DISPLAY
             * CORRECTLY                                                     */
            //AnnouncementAdapter.HasStableIds = true;

            /* Selecting the tab will automatically scroll back to the top   */
            /* of the list                                                   */
            TabLayout = ParentFragment.View.FindViewById <TabLayout>(
                Resource.Id.MainTabLayout);
            TabLayout.TabReselected += TabReselected;

            /* "Pulling" down on the page will refresh the view              */
            RefreshLayout =
                AnnouncementsView.FindViewById <SwipeRefreshLayout>(
                    Resource.Id.SwipeRefreshAnnouncements);

            RefreshLayout.SetColorSchemeResources(Resource.Color.primary,
                                                  Resource.Color.accent, Resource.Color.primary_text,
                                                  Resource.Color.secondary_text);
            RefreshLayout.Refresh += RefreshLayoutRefresh;

            /* Setup the recyclerview with the created adapter and layout    */
            /* manager                                                       */
            AnnouncementRecyclerView.SetLayoutManager(AnnouncementLayoutManager);
            AnnouncementRecyclerView.SetAdapter(AnnouncementAdapter);


            return(AnnouncementsView);
        }