protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.detalleRepuesto);
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            string key = Intent.GetStringExtra("idEntregaAlmacen");

            repuesto = ManagerRepuestos.getRepuestoByKey(key);

            SupportActionBar.Title = string.Format(@"{0} - {1}", repuesto.Cod_Producto, repuesto.Unit_of_Measure_Code);

            edittext              = FindViewById <EditText>(Resource.Id.textCantidad);
            edittext.TextChanged += Edittext_TextChanged;
            if (repuesto.Cantidad != 0)
            {
                edittext.Text = repuesto.Cantidad.ToString();
            }
            else
            {
                edittext.Text = string.Empty;
            }

            edittext.FocusChange += (sender, args) =>
            {
                bool isFocused = args.HasFocus;
                if (!isFocused)
                {
                    spinner_OnClick(sender);
                }
            };

            spinnerDestino = (Spinner)FindViewById(Resource.Id.spinnerDestino);

            spinnerDestino.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerDestino_ItemSelected);

            spinnerMaquina = (Spinner)FindViewById(Resource.Id.spinnerMaquina);
            spinnerMaquina.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerMaquina_ItemSelected);
            spinnerMaquina.Visibility    = ViewStates.Invisible;

            var s = (Destino[])Enum.GetValues(typeof(Destino));

            adapterDestinos = new AdapterSpinner <Destino>(this, Android.Resource.Layout.SimpleSpinnerItem, s);
            adapterDestinos.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerDestino.Adapter              = adapterDestinos;
            spinnerDestino.Focusable            = true;
            spinnerDestino.FocusableInTouchMode = true;
            spinnerDestino.RequestFocus(FocusSearchDirection.Up);

            var arrayMaquinas = (Maquina[])Enum.GetValues(typeof(Maquina));

            adapterMaquinas = new AdapterSpinner <Maquina>(this, Android.Resource.Layout.SimpleSpinnerItem, arrayMaquinas);
            adapterDestinos.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerMaquina.Adapter              = adapterMaquinas;
            spinnerMaquina.Focusable            = true;
            spinnerMaquina.FocusableInTouchMode = true;
            spinnerMaquina.RequestFocus(FocusSearchDirection.Up);

            TextView textDescription = FindViewById <TextView>(Resource.Id.textDescription);

            textDescription.Text = repuesto.Descripcion_Producto;

            Resources.GetDrawable(Android.Resource.Drawable.AlertLightFrame);
            warning = (Drawable)Resources.GetDrawable(Android.Resource.Drawable.AlertLightFrame);

            if (repuesto.Cantidad != 0)
            {
                spinnerDestino.SetSelection((int)repuesto.Destino);
                spinnerMaquina.SetSelection((int)repuesto.Maquina);
            }

            Button btoAceptar = FindViewById <Button>(Resource.Id.btoAceptar);

            btoAceptar.Click += OnClik_btoAceptar;

            progressLayout            = FindViewById <LinearLayout>(Resource.Id.progressBar);
            progressLayout.Visibility = ViewStates.Gone;
        }
示例#2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);

            var ignored = base.OnCreateView(inflater, container, savedInstanceState);

            view = inflater.Inflate(Resource.Layout.detalleRepuesto, null);


            string key    = string.Empty;
            Bundle bundle = this.Arguments;

            if (bundle != null)
            {
                key = bundle.GetString("idEntregaAlmacen");
            }
            repuesto = ManagerRepuestos.getRepuestoByKey(key);



            AppCompatActivity activity = (AppCompatActivity)this.Activity;

            activity.SupportActionBar.Title    = string.Format(@"Producto: {0}", repuesto.Cod_Producto);
            activity.SupportActionBar.Subtitle = string.Format(@"Unidad Medida: {0}", repuesto.Unit_of_Measure_Code);
            edittext = view.FindViewById <EditText>(Resource.Id.textCantidad);



            edittext.TextChanged += Edittext_TextChanged;
            if (repuesto.Cantidad != 0)
            {
                edittext.Text = repuesto.Cantidad.ToString();
            }
            else
            {
                edittext.Text = string.Empty;
            }

            //spinnerDestino.SetSelection(repuesto.) = 0;
            edittext.FocusChange += (sender, args) =>
            {
                bool isFocused = args.HasFocus;
                if (!isFocused)
                {
                    spinner_OnClick(sender);
                }
            };

            spinnerDestino = (Spinner)view.FindViewById(Resource.Id.spinnerDestino);

            spinnerDestino.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerDestino_ItemSelected);
            //spinnerDestino.ItemClick += spinner_OnClick;


            spinnerMaquina = (Spinner)view.FindViewById(Resource.Id.spinnerMaquina);

            spinnerMaquina.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerMaquina_ItemSelected);
            spinnerMaquina.Visibility    = ViewStates.Invisible;
            //spinnerMaquina.ItemClick += spinner_OnClick;


            var s = (Destino[])Enum.GetValues(typeof(Destino));

            adapterDestinos = new AdapterSpinner <Destino>(this.Activity, Android.Resource.Layout.SimpleSpinnerItem, s);
            // Specify the layout to use when the list of choices appears
            adapterDestinos.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            // Apply the adapter to the spinner
            spinnerDestino.Adapter = adapterDestinos;

            spinnerDestino.Focusable            = true;
            spinnerDestino.FocusableInTouchMode = true;
            spinnerDestino.RequestFocus(FocusSearchDirection.Up);

            //string[] Maquinas = new String[] { "M1", "M2", "M3", "M4", "R1", "R2", "R3", "R4", "T1", "T2", "T3", "T4", "T5", "T6", "T7", "T8" };

            var arrayMaquinas = (Maquina[])Enum.GetValues(typeof(Maquina));

            adapterMaquinas = new AdapterSpinner <Maquina>(this.Activity, Android.Resource.Layout.SimpleSpinnerItem, arrayMaquinas);
            // Specify the layout to use when the list of choices appears
            adapterDestinos.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            // Apply the adapter to the spinner
            spinnerMaquina.Adapter              = adapterMaquinas;
            spinnerMaquina.Focusable            = true;
            spinnerMaquina.FocusableInTouchMode = true;
            spinnerMaquina.RequestFocus(FocusSearchDirection.Up);

            TextView textDescription = view.FindViewById <TextView>(Resource.Id.textDescription);

            textDescription.Text = repuesto.Descripcion_Producto;



            Resources.GetDrawable(Android.Resource.Drawable.AlertLightFrame);
            warning = (Drawable)Resources.GetDrawable(Android.Resource.Drawable.AlertLightFrame);


            //spinnerDestino.Click += (object sender, EventArgs e) =>
            //{
            //    InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
            //    imm.HideSoftInputFromWindow(edittext.WindowToken, 0);
            //};


            Button btoAceptar = view.FindViewById <Button>(Resource.Id.btoAceptar);

            btoAceptar.Click += OnClik_btoAceptar;

            progressLayout            = view.FindViewById <LinearLayout>(Resource.Id.progressBarDetalle);
            progressLayout.Visibility = ViewStates.Gone;

            if (repuesto.Cantidad != 0)
            {
                spinnerDestino.SetSelection((int)repuesto.Destino);
                spinnerMaquina.SetSelection((int)repuesto.Maquina);
            }

            return(view);
        }