public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var root = inflater.Inflate(Resource.Layout.fragment_recyclerview, container, false);

            var recyclerView = root.FindViewById <RecyclerView>(Resource.Id.recycler_view);

            recyclerView.HasFixedSize = true;
            recyclerView.SetItemAnimator(new DefaultItemAnimator());
            recyclerView.SetLayoutManager(new LinearLayoutManager(Activity));
            recyclerView.AddItemDecoration(new DividerItemDecoration(Activity, DividerItemDecoration.VerticalList));

            var adapter = new RecyclerViewAdapter(Activity, Resources.GetStringArray(Resource.Array.countries));

            recyclerView.SetAdapter(adapter);

            var fab = root.FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.AttachToRecyclerView(recyclerView, this);
            fab.Size    = FabSize.Mini;
            fab.Enabled = false;
            fab.Click  += (sender, args) =>
            {
                Toast.MakeText(Activity, "FAB Clicked!", ToastLength.Short).Show();
            };
            return(root);
        }
Пример #2
0
    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
      var root = inflater.Inflate(Resource.Layout.fragment_recyclerview, container, false);

      var recyclerView = root.FindViewById<RecyclerView>(Resource.Id.recycler_view);
      recyclerView.HasFixedSize = true;
      recyclerView.SetItemAnimator(new DefaultItemAnimator());
      recyclerView.SetLayoutManager(new LinearLayoutManager(Activity));
      recyclerView.AddItemDecoration(new DividerItemDecoration(Activity, DividerItemDecoration.VerticalList));

      var adapter = new RecyclerViewAdapter(Activity, Resources.GetStringArray(Resource.Array.countries));
      recyclerView.SetAdapter(adapter);

      var fab = root.FindViewById<FloatingActionButton>(Resource.Id.fab);
      fab.AttachToRecyclerView(recyclerView, this);
      fab.Size = FabSize.Mini;
      fab.Click += (sender, args) =>
      {
        Toast.MakeText(Activity, "FAB Clicked!", ToastLength.Short).Show();
      };
      return root;
    }