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

            SetContentView(Resource.Layout.Carross);

            //var id = Intent.Extras.GetString("id");
            //var name = Intent.Extras.GetString("name");
            //var standarCost = Intent.Extras.GetString("standarCost");
            //string filaCarrito ="Producto: " +name + ", Precio:  " + standarCost;

            listProductos = readCarritoDB();

            //listProductos.Add(filaCarrito);
            ListView vista = FindViewById <ListView>(Resource.Id.listCarro);
            //ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, list.ToArray());
            ProductoItemAdapter adapter = new ProductoItemAdapter(this, listProductos.ToArray());

            vista.Adapter = adapter;

            Button botonback = FindViewById <Button>(Resource.Id.backMain);

            botonback.Click += Botonback_Click;

            vista.ItemLongClick += Vista_ItemLongClick;
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Carross);

            //var id = Intent.Extras.GetString("id");
            //var name = Intent.Extras.GetString("name");
            //var standarCost = Intent.Extras.GetString("standarCost");
            //string filaCarrito ="Producto: " +name + ", Precio:  " + standarCost;

            listProductos = readCarritoDB();

            //listProductos.Add(filaCarrito);
            ListView vista = FindViewById<ListView>(Resource.Id.listCarro);
            //ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, list.ToArray());
            ProductoItemAdapter adapter = new ProductoItemAdapter(this, listProductos.ToArray());
            vista.Adapter = adapter;

            Button botonback = FindViewById<Button>(Resource.Id.backMain);
            botonback.Click += Botonback_Click;

            vista.ItemLongClick += Vista_ItemLongClick;

        }
Ejemplo n.º 3
0
        private void Vista_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            ListView lista    = (ListView)sender;
            Producto producto = (Producto)lista.GetItemAtPosition(e.Position);

            foreach (Producto p in listProductos)
            {
                if (producto == p)
                {
                    var aviso = new AlertDialog.Builder(this);
                    aviso.SetMessage("¿Desea eliminar " + producto.Name + "?");
                    aviso.SetPositiveButton("Aceptar", delegate {
                        deleteProductDb(p);
                        listProductos = readCarritoDB();
                        ProductoItemAdapter adapter = new ProductoItemAdapter(this, listProductos.ToArray());
                        lista.Adapter = adapter;
                    });
                    aviso.SetNegativeButton("Cancelar", delegate { });
                    aviso.Show();
                }
            }
        }
        private void MostrarRangoProductos()
        {
            indiceIni = (indiceIni < 0) ? 0 : indiceIni;
            indiceIni = (indiceIni >= listaProductos.Count) ? listaProductos.Count - 1 : indiceIni;
            indiceFin = (indiceFin < 0) ? 0 : indiceFin;
            indiceFin = (indiceFin >= listaProductos.Count) ? listaProductos.Count - 1 : indiceFin;

            Producto[]          productos = listaProductos.GetRange(indiceIni, indiceFin - indiceIni + 1).ToArray();
            ProductoItemAdapter adapter   = new ProductoItemAdapter(this, productos);

            listaProd.Adapter = adapter;

            buttonAnterior.Enabled  = (indiceIni == 0) ? false : true;
            buttonSiguiente.Enabled = (indiceFin == listaProductos.Count - 1) ? false : true;


            textoPagina.Text = (indiceIni + 1).ToString() + " - " + (indiceFin + 1).ToString() + " de " + listaProductos.Count.ToString();

            if (indiceFin == listaProductos.Count - 1)
            {
                indiceFin = (indiceIni + ELEM_POR_PAG - 1);
            }
        }
Ejemplo n.º 5
0
        private void Vista_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            ListView lista = (ListView)sender;
            Producto producto = (Producto)lista.GetItemAtPosition(e.Position);
            foreach (Producto p in listProductos)
            {
                if (producto == p)
                {
                    var aviso = new AlertDialog.Builder(this);
                    aviso.SetMessage("¿Desea eliminar " + producto.Name + "?");
                    aviso.SetPositiveButton("Aceptar", delegate {
                        deleteProductDb(p);
                        listProductos = readCarritoDB();
                        ProductoItemAdapter adapter = new ProductoItemAdapter(this, listProductos.ToArray());
                        lista.Adapter = adapter;
                    });
                    aviso.SetNegativeButton("Cancelar", delegate { });
                    aviso.Show();
                }
            }

            
        }
        private void MostrarRangoProductos()
        {
            indiceIni = (indiceIni < 0) ? 0 : indiceIni;
            indiceIni = (indiceIni >= listaProductos.Count) ? listaProductos.Count - 1 : indiceIni;
            indiceFin = (indiceFin < 0) ? 0 : indiceFin;
            indiceFin = (indiceFin >= listaProductos.Count) ? listaProductos.Count - 1 : indiceFin;

            Producto[] productos = listaProductos.GetRange(indiceIni, indiceFin - indiceIni + 1).ToArray();
            ProductoItemAdapter adapter = new ProductoItemAdapter(this, productos);
            listaProd.Adapter = adapter;

            buttonAnterior.Enabled = (indiceIni == 0) ? false : true;
            buttonSiguiente.Enabled = (indiceFin == listaProductos.Count - 1) ? false : true;


            textoPagina.Text = (indiceIni + 1).ToString() + " - " + (indiceFin + 1).ToString() + " de " + listaProductos.Count.ToString();

            if (indiceFin == listaProductos.Count - 1)
            {
                indiceFin = (indiceIni + ELEM_POR_PAG - 1);
            }
        }