protected async override void OnCreate(Bundle savedInstanceState) { // Instantiate the photo album: mPhotoAlbum = new PhotoAlbum(); base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); //DrawerLayout fragment drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); var toolbar = FindViewById <V7Toolbar>(Resource.Id.toolbar); // Create ActionBarDrawerToggle button and add it to the toolbar SetSupportActionBar(toolbar); var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.drawer_open, Resource.String.drawer_close); drawerLayout.AddDrawerListener(drawerToggle); drawerToggle.SyncState(); navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); setupDrawerContent(navigationView); //Calling Function mRecyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); // Get our RecyclerView layout: eventlist = new EventCollection(); //............................................................ // Layout Manager Setup: mLayoutManager = new LinearLayoutManager(this); // Use the built-in linear layout manager: // Or use the built-in grid layout manager (two horizontal rows): // mLayoutManager = new GridLayoutManager // (this, 2, GridLayoutManager.Horizontal, false); var onScrollListener = new XamarinRecyclerViewOnScrollListener(mLayoutManager); onScrollListener.LoadMoreEvent += async(object sender, MyEventArgs e) => { var eventos = await eventlist.LoadEvents(pageLenght : e.ItemCount + 10); mAdapter.NotifyDataSetChanged(); }; mRecyclerView.AddOnScrollListener(onScrollListener); mRecyclerView.SetLayoutManager(mLayoutManager); // Plug the layout manager into the RecyclerView: //............................................................ // Adapter Setup: // Create an adapter for the RecyclerView, and pass it the // data set (the photo album) to manage: //mAdapter = new PhotoAlbumAdapter(mPhotoAlbum); var eventos = await eventlist.LoadEvents(); mAdapter = new PhotoAlbumAdapter(eventos); mAdapter.ItemClick += OnItemClick; // Register the item click handler (below) with the adapter: mRecyclerView.SetAdapter(mAdapter); // Plug the adapter into the RecyclerView: //............................................................ // Random Pick Button: /* * // Get the button for randomly swapping a photo: * Button randomPickBtn = FindViewById<Button>(Resource.Id.randPickButton); * * // Handler for the Random Pick Button: * randomPickBtn.Click += delegate * { * if (mPhotoAlbum != null) * { * // Randomly swap a photo with the top: * int idx = mPhotoAlbum.RandomSwap(); * * // Update the RecyclerView by notifying the adapter: * // Notify that the top and a randomly-chosen photo has changed (swapped): * mAdapter.NotifyItemChanged(0); * mAdapter.NotifyItemChanged(idx); * } * };*/ }
EventCollection mPhotoAlbum; // Underlying data set (a photo album): //public PhotoAlbumAdapter(PhotoAlbum photoAlbum) // Load the adapter with the data set (photo album) at construction time: public PhotoAlbumAdapter(EventCollection photoAlbum) // Load the adapter with the data set (photo album) at construction time: { mPhotoAlbum = photoAlbum; }