예제 #1
0
 // Main Activity MUST be loaded.
 public static CState GetCSTate(Activity mn)
 {
     Android.Widget.CheckBox _searchChk        = mn.FindViewById <Android.Widget.CheckBox>(Resource.Id.options_search);
     Android.Widget.CheckBox _MTChk            = mn.FindViewById <Android.Widget.CheckBox>(Resource.Id.options_multithread);
     Android.Widget.CheckBox _exportEpub       = mn.FindViewById <Android.Widget.CheckBox>(Resource.Id.options_exportEpub);
     Android.Widget.CheckBox _continueDownload = mn.FindViewById <Android.Widget.CheckBox>(Resource.Id.options_continue);
     Android.Widget.CheckBox _skipDownloaded   = mn.FindViewById <Android.Widget.CheckBox>(Resource.Id.options_skip);
     Android.Widget.EditText input             = mn.FindViewById <EditText>(Resource.Id.editText1);
     return(new CState(_searchChk.Checked, _MTChk.Checked, _exportEpub.Checked, _continueDownload.Checked, _skipDownloaded.Checked)
     {
         term = input.Text
     });
 }
예제 #2
0
        public void mostrarVentanaAgregartexto(int idCampo, string titulo)
        {
            //Se crea el layoutInflater en base a la actividad que esta ejecutando el fragmento actual
            LayoutInflater layoutInflater = LayoutInflater.From(this);
            //Se crea la vista que contiene los controles que muestra la ventana de observaciones
            View contenedorVentanaModal = layoutInflater.Inflate(Resource.Layout.VentanaObservaciones, null);

            //Se instancia el constructor de la ventana
            Android.App.AlertDialog.Builder constructorVentana = new Android.App.AlertDialog.Builder(this);
            constructorVentana.SetView(contenedorVentanaModal);//Se agrega la vista que va a mostrar la ventana de observaciones

            //Se crea la instancia del edit text donde se colocara la observación
            Android.Widget.EditText observacion = (Android.Widget.EditText)contenedorVentanaModal.FindViewById(Resource.Id.txtObservacionesVentana);
            //Se cambia el titulo de la ventana
            Android.Widget.TextView tituloVentana = (Android.Widget.TextView)contenedorVentanaModal.FindViewById(Resource.Id.txtTituloVentana);
            tituloVentana.Text = titulo;

            //Se crea la instancia del edit text al que se le asignara el texto de la ventana
            Android.Widget.EditText campoTexto = (Android.Widget.EditText) this.FindViewById(idCampo);
            //Se evalua el campo de texto, si no esta vacio se asigna al campo de texto de la ventana
            if (campoTexto.Text != "")
            {
                observacion.Text = campoTexto.Text;//Se realiza la asignación del texto
            }
            //Se agregan los eventos para los botones de cancelar y de Aceptar
            constructorVentana.SetCancelable(false).SetPositiveButton("Aceptar", (sender, args) => {
                //Al presionar el botón de Aceptar se asigna el texto agregado en la ventana
                //en el campo de texto
                campoTexto.Text = observacion.Text;
            }).SetNegativeButton("Cancelar", (sender, args) => {
                //Evento al presionar el botón de cancelar
            }).SetNeutralButton("Borrar todo", (System.EventHandler <DialogClickEventArgs>)null);

            //Se crea la ventana de dialogo y se instancia con el constructor de la ventana creado anteriormente
            Android.App.AlertDialog ventana = constructorVentana.Create();
            ventana.Show();//Se muestra la ventana

            //Se crea una instancia del botón neutral de la ventana
            var btnBorrar = ventana.GetButton((int)DialogButtonType.Neutral);

            //Se crea el evento al presionar el botón de borrar
            btnBorrar.Click += (sender, args) => {
                observacion.Text = "";//Se limpia el texto de la ventana
            };
        }
예제 #3
0
        protected override void OnElementChanged(ElementChangedEventArgs <CustomTextEditView> e)
        {
            base.OnElementChanged(e);

            //Element is the virtual control that's being rendered in the renderer, e.g. Button, Entry, Frame etc.   Element : CustomTextEditView
            //Control is the platform implementation of that control, e.g.UIButton/Button, etc.                      Control : EditText

            if (Control == null && Element != null)
            {
                CustomTextEditView view = Element as CustomTextEditView;
                editText   = new DisEditText(Context, view);
                scrollView = new Android.Widget.ScrollView(Context);
                scrollView.AddView(editText);
                view.SetEditText(scrollView, editText); // export editText so we can use it from CustomTextEditView methods
                SetNativeControl(scrollView);
            }
            if (e.OldElement != null)
            {
                // Unsubscribe events
                CustomTextEditView view = e.OldElement as CustomTextEditView;
                if (view.textChangedDelegate != null)
                {
                    editText.AfterTextChanged -= view.textChangedDelegate;
                }
                if (view.focusChangeDelegate != null)
                {
                    editText.FocusChange -= view.focusChangeDelegate;
                }
            }
            if (e.NewElement != null)
            {
                // Subscribe events
                CustomTextEditView view = e.NewElement as CustomTextEditView;
                if (view.textChangedDelegate != null)
                {
                    editText.AfterTextChanged += view.textChangedDelegate;
                }
                if (view.focusChangeDelegate != null)
                {
                    editText.FocusChange += view.focusChangeDelegate;
                }
            }
        }
예제 #4
0
 private void GetControles()
 {
     try
     {
         txtBairro    = FindViewById <Android.Widget.EditText>(Resource.Id.txtBairro);
         txtCEP       = FindViewById <Android.Widget.EditText>(Resource.Id.txtCEP);
         txtCidade    = FindViewById <Android.Widget.EditText>(Resource.Id.txtCidade);
         txtDocumento = FindViewById <Android.Widget.EditText>(Resource.Id.txtDocumento);
         txtEndereco  = FindViewById <Android.Widget.EditText>(Resource.Id.txtEndereco);
         txtNumero    = FindViewById <Android.Widget.EditText>(Resource.Id.txtNumero);
         txtRazao     = FindViewById <Android.Widget.EditText>(Resource.Id.txtRazao);
         txtTelefone  = FindViewById <Android.Widget.EditText>(Resource.Id.txtTelefone);
         spEstado     = FindViewById <Android.Widget.Spinner>(Resource.Id.spEstado);
         rbTPCNPJ     = FindViewById <Android.Widget.RadioButton>(Resource.Id.rbCNPJ);
         rbTPCPF      = FindViewById <Android.Widget.RadioButton>(Resource.Id.rbCPF);
     }
     catch (System.Exception)
     {
         Android.Widget.Toast.MakeText(this, "Erro ao receber controles.", Android.Widget.ToastLength.Short).Show();
     }
 }
예제 #5
0
        }//ShowError

        public static void HideError(this Android.Widget.EditText txtEdit)
        {
            txtEdit.SetError((string)null, null);
            txtEdit.SetCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
        }//HideError
예제 #6
0
 /// <summary>
 /// ShowError
 /// </summary>
 /// <param name="txtEdit"></param>
 /// <param name="sErrorMsg"></param>
 public static void ShowError(this Android.Widget.EditText txtEdit, string sErrorMsg, Context cnt)
 {
     Android.Graphics.Drawables.Drawable icon = ContextCompat.GetDrawable(cnt, Resource.Drawable.val_error);
     txtEdit.SetError(sErrorMsg, null);
     txtEdit.SetCompoundDrawablesWithIntrinsicBounds(0, 0, Resource.Drawable.val_error, 0);
 }//ShowError
예제 #7
0
            public Dialog AndroidCustomAlert(Activity activ)
            {
                Android.Views.LayoutInflater inflater = Android.Views.LayoutInflater.From(activ);
                Android.Views.View           view     = inflater.Inflate(Resource.Layout.AlertDialogLayout, null);

                AlertDialog.Builder builder = new AlertDialog.Builder(activ);
                builder.SetView(view);
                Android.Widget.TextView title = view.FindViewById <Android.Widget.TextView>(Resource.Id.Login);
                title.Text = Title;

                Android.Widget.TextView body = view.FindViewById <Android.Widget.TextView>(Resource.Id.pincodeText);
                body.Text = Body;

                Android.Widget.EditText pincode     = view.FindViewById <Android.Widget.EditText>(Resource.Id.pincodeEditText);
                Android.Widget.Button   btnPositive = view.FindViewById <Android.Widget.Button>(Resource.Id.btnLoginLL);
                Android.Widget.Button   btnNegative = view.FindViewById <Android.Widget.Button>(Resource.Id.btnClearLL);
                Android.Widget.Button   btnNeutral  = view.FindViewById <Android.Widget.Button>(Resource.Id.btnNeutral);

                if (Title.Contains("Tijd"))
                {
                    Android.Views.View secondView = inflater.Inflate(Resource.Layout.TimePickerLayout, null);
                    builder.SetView(secondView);

                    btnPositive = secondView.FindViewById <Android.Widget.Button>(Resource.Id.btnLoginLL);
                    btnNegative = secondView.FindViewById <Android.Widget.Button>(Resource.Id.btnClearLL);
                    var tp = secondView.FindViewById <Android.Widget.TimePicker>(Resource.Id.timePicker1);
                    tp.SetIs24HourView((Java.Lang.Boolean)true);
                    //Positive button feedback
                    btnPositive.Text   = Buttons.Last().Text;
                    btnPositive.Click += delegate
                    {
                        var car = (Xamarin.Forms.TimePicker)Content;
                        var ts  = new TimeSpan(tp.Hour, tp.Minute, 0);
                        car.Time = ts;

                        CommandsForButtons(Buttons.Last());
                    };

                    //Negative button feedback
                    btnNegative.Text   = Buttons.First().Text;
                    btnNegative.Click += delegate
                    {
                        CommandsForButtons(Buttons.First());
                    };
                }
                else if (Title.Contains("Hoe gaat het"))
                {
                    btnPositive.Visibility = Android.Views.ViewStates.Gone;
                    btnNegative.Visibility = Android.Views.ViewStates.Gone;
                    btnNeutral.Visibility  = Android.Views.ViewStates.Visible;

                    var happySlider = view.FindViewById <Android.Widget.SeekBar>(Resource.Id.happinessSlider);
                    happySlider.SetProgress(5, false);
                    happySlider.Visibility = Android.Views.ViewStates.Visible;
                    btnNeutral.Text        = Buttons.First().Text;
                    btnNeutral.Click      += delegate
                    {
                        var car             = (Xamarin.Forms.Slider)Content;
                        var totalHappyValue = happySlider.Progress / 10;
                        car.Value = totalHappyValue;

                        CommandsForButtons(Buttons.First());
                    };
                }
                else
                {
                    //Checks if there are no buttons, and if there aren't any, creates a neutral one
                    if (Buttons == null || Buttons.Count == 0)
                    {
                        btnPositive.Visibility = Android.Views.ViewStates.Gone;
                        btnNegative.Visibility = Android.Views.ViewStates.Gone;
                        btnNeutral.Visibility  = Android.Views.ViewStates.Visible;
                        pincode.Visibility     = Android.Views.ViewStates.Gone;

                        Buttons = new List <AlertButton> {
                            new AlertButton {
                                Text        = "Oké",
                                IsPreferred = true,
                                Action      = () => false
                            }
                        };
                        btnNeutral.Text   = Buttons.First().Text;
                        btnNeutral.Click += delegate
                        {
                            CommandsForButtons(Buttons.First());
                        };
                    }

                    if (Content == null)
                    {
                        pincode.Visibility = Android.Views.ViewStates.Gone;
                    }

                    //Positive button feedback
                    btnPositive.Text   = Buttons.Last().Text;
                    btnPositive.Click += delegate
                    {
                        var test = (StackLayout)Content;
                        var car  = (Entry)test.Children[0];
                        car.Text = pincode.Text;


                        CommandsForButtons(Buttons.Last());
                    };

                    //Negative button feedback
                    btnNegative.Text   = Buttons.First().Text;
                    btnNegative.Click += delegate
                    {
                        CommandsForButtons(Buttons.First());
                    };
                }

                builder.SetCancelable(false);
                return(builder.Create());
            }