private void spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { Spinner spinner = (Spinner)sender; string opcion = (string)spinner.GetItemAtPosition(e.Position); List <ProductModel> aux = getProductosPorCategoria(opcion); var progressDialog = ProgressDialog.Show(this, "Espere un momento", "Obteniendo PRODUCTOS", true); a = new ProductosAdapter(aux, this); a.ItemClick += OnItemClick; mRecyclerView.SetAdapter(a); progressDialog.Dismiss(); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.menu_activity); //toolbar var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetActionBar(toolbar); ActionBar.Title = "Productos"; mRecyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); spCategorias = FindViewById <Spinner>(Resource.Id.spCategorias); mLayoutManager = new GridLayoutManager(this, 2, GridLayoutManager.Vertical, false); //mLayoutManager = new LinearLayoutManager(this); mRecyclerView.SetLayoutManager(mLayoutManager); var progressDialog = ProgressDialog.Show(this, "Espere un momento", "Obteniendo Productos", true); //PRODUCTOS recycle ProductList = await getProductos(); ProductosAdapter = new ProductosAdapter(ProductList, this); ProductosAdapter.ItemClick += OnItemClick; mRecyclerView.SetAdapter(ProductosAdapter); //CATEGORIAS spinner classes2 = await getCategorias2(); adapter = new ArrayAdapter <string>( this, Android.Resource.Layout.SimpleListItem1, classes2); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spCategorias.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected); spCategorias.Adapter = adapter; progressDialog.Dismiss(); //btnCarritoG.Click += mostrarCarrito; }