Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            vegeList = new List<Vegetable> () {
                new Vegetable (1,"Onion",0,false,10, Resource.Drawable.rsz_onion_images),
                new Vegetable (2,"Cucumber",0,false,10, Resource.Drawable.rsz_cucumber),
                new Vegetable (3,"Carrot",0,false,10, Resource.Drawable.rsz_carrot),
            };
            // Get our button from the layout resource,
            // and attach an event to it
            Button btnReset = FindViewById<Button> (Resource.Id.myButton);

            // Get our RecyclerView layout:
            mRecyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerView);

            // Use the built-in linear layout manager:
            mLayoutManager = new LinearLayoutManager(this);

            // Plug the layout manager into the RecyclerView:
            mRecyclerView.SetLayoutManager(mLayoutManager);

            // Create an adapter for the RecyclerView, and pass it the
            // data set (the photo album) to manage:
            mAdapter = new RecycleAdapter(this,vegeList);

            // Register the item click handler (below) with the adapter:
            mAdapter.ItemClick += OnItemClick;
            mAdapter.SpinnerItemSelectionChanged += SpinnerItemSelectionChangedEvent;

            // Plug the adapter into the RecyclerView:
            mRecyclerView.SetAdapter(mAdapter);

            //Reset the complete view;
            btnReset.Click += delegate {
                if(vegeList!=null)
                {
                    for(int i=0;i<vegeList.Count;i++)
                    {
                        vegeList[i].Quantity = 0;
                    }
                    mAdapter.NotifyDataSetChanged();
                }

            };
        }