private void ExamNameTV_Click(object sender, ExamAdapterClickEventArgs e) { ExamModel examname_clicked = this.ExamList[e.Position]; string examname = examname_clicked.get_exam_name(); Dialog nameDialog = new Dialog(this); nameDialog.SetContentView(Resource.Id.dialog_name_update); EditText editText = (EditText)nameDialog.FindViewById(Resource.Id.dialog_name_editText); editText.Text = examname; /* Non riconosce più android.support.design e quindi ho messo il design che sta in google.design*/ TextInputLayout textInputLayout = (TextInputLayout)nameDialog.FindViewById(Resource.Id.dialog_name_input_layout); Android.Widget.Button okButton = (Android.Widget.Button)nameDialog.FindViewById(Resource.Id.name_ok); okButton.Click += async delegate { string examNameNew = editText.Text.ToUpper(); if (examNameNew.Trim().Equals("")) { textInputLayout.SetErrorTextAppearance(Resource.String.empty_name_field); textInputLayout.RequestFocus(); } else if (examNameNew.Length > 15) { textInputLayout.SetErrorTextAppearance(Resource.String.overflow_name_field); textInputLayout.RequestFocus(); } else if (IsSameName(examNameNew)) { textInputLayout.SetErrorTextAppearance(Resource.String.used_name); textInputLayout.RequestFocus(); } else { /* * Google.Cloud.Firestore.CollectionReference exams = database.Collection("exams"); * Google.Cloud.Firestore.DocumentReference examDoc = exams.Document(examname); * Google.Cloud.Firestore.DocumentSnapshot snapshot = await examDoc.GetSnapshotAsync(); * if (snapshot.Exists) * { * await exams.Document(examNameNew).SetAsync(snapshot); * await examDoc.DeleteAsync(); * } */ } bool IsSameName(string examNewName) { for (int j = 0; j < adapter.ItemCount; j++) { if (ExamList[j].examName.Equals(examNewName)) { return(true); } } return(false); } }; } }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { if (requestCode == (int)ActivityCodes.Activate && resultCode == Result.Ok) { Finish(); } else if (requestCode == (int)ActivityCodes.Register && resultCode == Result.Ok) { if (!ProxyFactory.GetProxyInstace().IsAuthenticated) { // Go to Home string username = data.GetStringExtra("username"); string password = data.GetStringExtra("password"); // tbUsername.EditText.Text = username; tbPassword.EditText.Text = password; // tbUsername.RequestFocus(); tbUsername.EditText.SelectAll(); } else { // Finish(); } } base.OnActivityResult(requestCode, resultCode, data); }
private void EditName(object sender, EventArgs e) { _editText = (TextInputLayout)LayoutInflater.Inflate(Resource.Layout.edit_name, null); _editText.EditText.Text = Vm.Debt.Name; _editText.EditText.Gravity = Android.Views.GravityFlags.Center; using (var alert = new AlertDialog.Builder(MainActivity.Current)) { alert.SetView(_editText) .SetPositiveButton(Resource.String.save, (s, ev) => { }) .SetNeutralButton(Resource.String.cancel, (s, ev) => { HideKeyboard(); }) .SetOnDismissListener(this); _dialog = alert.Create(); } _dialog.Show(); _dialogPositiveButton = _dialog.GetButton((int)DialogButtonType.Positive); _dialogNegativeButton = _dialog.GetButton((int)DialogButtonType.Neutral); _dialogPositiveButton.Click += HandleDialogPositiveButtonClick; _dialogNegativeButton.Click += HandleDialogNegativeButtonClick; _editText.EditText.TextChanged += OnTextChanged; _editText.RequestFocus(); ShowKeyboard(); }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); var appbarMain = view.FindViewById <AppBarLayout>(Resource.Id.enter_phone_appbar); var toolbarMain = appbarMain.FindViewById <Toolbar>(Resource.Id.main_toolbar); var countryLinear = view.FindViewById <ConstraintLayout>(Resource.Id.cpicker_lin); phoneEt = view.FindViewById <TextInputLayout>(Resource.Id.enter_phone_et); nextBtn = view.FindViewById <MaterialButton>(Resource.Id.enter_cont_btn); countryFlagIv = view.FindViewById <ImageView>(Resource.Id.cflag_iv); dialcodeTv = view.FindViewById <TextView>(Resource.Id.dialcode_tv); ((AppCompatActivity)Activity).SetSupportActionBar(toolbarMain); ((AppCompatActivity)Activity).SupportActionBar.SetDisplayHomeAsUpEnabled(true); toolbarMain.Title = "Enter phone"; toolbarMain.NavigationClick += ToolbarMain_NavigationClick; builder = new CountryPicker.Builder().With(Context).Listener(new CountryPickerListener((c) => { countryFlagIv.SetImageResource(c.Flag); dialcodeTv.Text = c.DialCode; phoneEt.RequestFocus(); })); picker = builder.Build(); var country = picker.CountryFromSIM; countryFlagIv.SetImageResource(country.Flag); dialcodeTv.Text = country.DialCode; phoneEt.RequestFocus(); phoneEt.EditText.TextChanged += EditText_TextChanged; countryLinear.Click += CountryLinear_Click; nextBtn.Click += NextBtn_Click; }
protected bool ValidateInputs() { if (tbUsername.EditText.TrimInput().Length == 0) { ShowSnack("Please enter your username or email"); tbUsername.RequestFocus(); return(false); } if (tbPassword.EditText.TrimInput().Length == 0) { ShowSnack("Enter your password to begin"); tbPassword.RequestFocus(); return(false); } return(true); }