private void setCoordinateInputOutOfRangeError(boolean latitude) { if (latitude) { latitudeTextInputLayout.setError(getString(R.string.error_latitude_out_of_range)); } else { longitudeTextInputLayout.setError(getString(R.string.error_longitude_out_of_range)); } }
private void initView() { type = (RadioGroup) findViewById(R.id.rg_questiontype); topic = (TextInputLayout) findViewById(R.id.questiontopic); option_a = (TextInputLayout) findViewById(R.id.option_a); option_b = (TextInputLayout) findViewById(R.id.option_b); option_c = (TextInputLayout) findViewById(R.id.option_c); option_d = (TextInputLayout) findViewById(R.id.option_d); submit = (AppCompatButton) findViewById(R.id.submit); // choice = (AppCompatRadioButton) findViewById(R.id.type_choice); // judge = (AppCompatRadioButton) findViewById(R.id.type_judgment); hint = (AppCompatTextView) findViewById(R.id.questionimage_hint); progressBar = (CircularProgressBar) findViewById(R.id.cpb); upload = (AppCompatTextView) findViewById(R.id.upload); image = (ImageButton) findViewById(R.id.questionimage); type.setOnCheckedChangeListener(this); image.setOnClickListener(this); image.setOnLongClickListener(this); submit.setOnClickListener(this); topic.getEditText().setOnFocusChangeListener(this); option_a.getEditText().setOnFocusChangeListener(this); option_b.getEditText().setOnFocusChangeListener(this); option_c.getEditText().setOnFocusChangeListener(this); option_d.getEditText().setOnFocusChangeListener(this); topic.setHint(getString(R.string.question_titlehint)); option_a.setHint(getString(R.string.result_right)); option_b.setHint(getString(R.string.result_false)); option_c.setHint(getString(R.string.result_false)); option_d.setHint(getString(R.string.result_false)); }
private void initVars() { mDialog = new ProgressDialog(this); mProductAddNew = new Product() { { set_id(ProductAdapter.ACTION_ID_ADD); setName(getString(R.string.action_add_product)); } }; // --- Product --- spinner_Product_init(); // khởi tạo giá trị qua Intent mAssignId = getIntent().getLongExtra(EXTRA_ASSIGN_ID, -1); long mPSId = getIntent().getLongExtra(EXTRA_PRODUCT_SHOWN_ID, -1); if (mPSId == -1) { isAddNew = true; } else { // Hiển thị Cập nhật updateUIAddOrEdit(false); isAddNew = false; mProductShown = ProductShownData.getById(this, mPSId); spinner_Product_setSelection(mProductShown.getProductId()); mInputLayout_Number.getEditText().setText(mProductShown.getNumber() + ""); mInputLayout_RetailPrice.getEditText().setText(mProductShown.getRetailPrice() + ""); } }
private long addProductShown() { // lấy giá trị Product product = (Product) mSpinner_Product.getSelectedItem(); long productId = product.get_id(); int number = Integer.valueOf(mInputLayout_Number.getEditText().getText() + ""); long retailPrice = Long.valueOf(mInputLayout_RetailPrice.getEditText().getText() + ""); // gán giá trị mProductShown = new ProductShown(); mProductShown.setAssignId(mAssignId); mProductShown.setProductId(productId); mProductShown.setNumber(number); mProductShown.setRetailPrice(retailPrice); mProductShown.setSessionCode(DatabaseUtil.getCodeGenerationByTime()); mProductShown.setCreateBy(UserPref.getUserPrefId(this)); mProductShown.setCreateAt(Calendar.getInstance()); mProductShown.setUploadStatus(UploadStatus.WAITING_UPLOAD); long id = ProductShownData.add(this, mProductShown); mProductShown.set_id(id); return id; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_text_input_layout); final TextInputLayout textInputLayout = (TextInputLayout) findViewById(R.id.my_input_layout); EditText editText = textInputLayout.getEditText(); textInputLayout.setHint("Password"); editText.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.length() > 4) { textInputLayout.setError("Password error"); textInputLayout.setErrorEnabled(true); } else { textInputLayout.setErrorEnabled(false); } } @Override public void afterTextChanged(Editable s) {} }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.third_activity); btn = (Button) findViewById(R.id.btn); final TextInputLayout usernameWrapper = (TextInputLayout) findViewById(R.id.usernameWrapper); final TextInputLayout passwordWrapper = (TextInputLayout) findViewById(R.id.passwordWrapper); usernameWrapper.setHint("Username"); passwordWrapper.setHint("Password"); btn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(); // 获取到输入输入框里的内容 String username = usernameWrapper.getEditText().getText().toString(); String password = usernameWrapper.getEditText().getText().toString(); if (!validateEmail(username)) { usernameWrapper.setError("Not a valid email address!"); } else if (!validatePassword(password)) { passwordWrapper.setError("Not a valid password!"); } else { usernameWrapper.setErrorEnabled(false); passwordWrapper.setErrorEnabled(false); doLogin(); } } }); }
private void compute(Context context) { if (name.getText().toString().equals("")) { nameLay.setError(getString(R.string.err_input)); nameLay.setErrorEnabled(true); } else { int dateNaiss = picker.getYear(); int age = Calendar.getInstance().get(Calendar.YEAR) - dateNaiss; String res; if (man.isChecked()) { res = "Mon cher " + name.getText().toString() + " tu as " + age + " ans"; Toast.makeText(context, res, Toast.LENGTH_LONG).show(); } else { res = "Ma chere " + name.getText().toString() + " tu as " + age + " ans"; Toast.makeText(context, res, Toast.LENGTH_LONG).show(); } if (age == 18) { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("http://fr.wikipedia.org/wiki/Majorité"))); } else { Intent message = new Intent(this, Message.class); message.putExtra("MESSAGE", res); startActivity(message); } } }
@Override public void onRefresh() { AnonymousAccess.setChecked(false); textInputLayoutpasswords.getEditText().setText(""); textInputLayoutusername.getEditText().setText(""); textInputLayoutport.getEditText().setText(""); textInputLayoutdir.getEditText().setText(""); clean.setRefreshing(false); }
private void clearCoordinateInputOutOfRangeError(boolean latitude) { if (latitude) { latitudeTextInputLayout.setError(null); latitudeTextInputLayout.setErrorEnabled(false); } else { longitudeTextInputLayout.setError(null); longitudeTextInputLayout.setErrorEnabled(false); } }
@Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.length() <= 0) { mTextInputLayout.setErrorEnabled(true); mTextInputLayout.setError(mContext.getString(R.string.dialog_host_main_null)); } else { mTextInputLayout.setErrorEnabled(false); } }
@Override public void setField(RealmObject object) { Member member = (Member) object; vorname.getEditText().setText(member.getFirstName()); nachname.getEditText().setText(member.getLastName()); email.getEditText().setText(member.getEmail()); address.getEditText().setText(member.getAddress()); date.getEditText().setText(member.getBirthday()); }
public static boolean isEditTextFilled( Context context, EditText email, TextInputLayout inputLayout, int errorStringRes) { if (TextUtils.isEmpty(email.getText())) { inputLayout.setErrorEnabled(true); inputLayout.setError(context.getString(errorStringRes)); return false; } return true; }
@Override public RealmObject createDBObject() { return new Member( vorname.getEditText().getText().toString(), nachname.getEditText().getText().toString(), date.getEditText().getText().toString(), email.getEditText().getText().toString(), address.getEditText().getText().toString()); }
public void initEditText() { textInputLayoutusername = (TextInputLayout) findViewById(R.id.tiusername); textInputLayoutpasswords = (TextInputLayout) findViewById(R.id.tiuserpasswords); textInputLayoutport = (TextInputLayout) findViewById(R.id.tiuserport); textInputLayoutdir = (TextInputLayout) findViewById(R.id.tidir); textInputLayoutpasswords.setHint(getString(R.string.passwordhint)); textInputLayoutusername.setHint(getString(R.string.usernamehint)); textInputLayoutport.setHint(getString(R.string.porthint)); textInputLayoutdir.setHint(getString(R.string.pathhint)); }
/** * Errorメッセージのくだり * * @return */ private boolean validateServiceName() { if (rrptxvservice.getText().toString().trim().isEmpty()) { rrpTilServicename.setError(getString(R.string.err_msg_servicename)); requestFocus(rrptxvservice); return false; } else { rrpTilServicename.setErrorEnabled(false); } return true; }
@Before public void setUp() { final ActivityController<Activity> activityController = buildActivity(Activity.class); final Activity activity = activityController.create().get(); activityController.start().resume().visible(); TextInputLayout textInputLayout; activity.setContentView(textInputLayout = new TextInputLayout(activity)); textInputLayout.addView(editText = new EditText(activity)); editText.setText("0,00"); }
private boolean validateEmail() { String EMAIL_PATTERN = "^[a-zA-Z0-9#_~!$&'()*+,;=:.\"(),:;<>@\\[\\]\\\\]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*$"; Pattern pattern = Pattern.compile(EMAIL_PATTERN); Matcher matcher = null; if (!validateEmailasd(pattern, matcher, email.getEditText().toString())) { email.setError("Not a valid email address!"); return true; } return true; }
public void visibilityLoadOff() { email.setVisibility(View.VISIBLE); nombre.setVisibility(View.VISIBLE); apellido.setVisibility(View.VISIBLE); contraseña1.setVisibility(View.VISIBLE); contraseña2.setVisibility(View.VISIBLE); imagen.setVisibility(View.VISIBLE); dueño.setVisibility(View.VISIBLE); textView.setVisibility(View.VISIBLE); progressBar.setVisibility(View.GONE); }
private boolean validatePassword() { if (inputPassword.getText().toString().trim().isEmpty()) { inputLayoutPassword.setError(getString(R.string.err_msg_password)); setKeyboardFocus(inputPassword); return false; } else { inputLayoutPassword.setErrorEnabled(false); } return true; }
private boolean validatePassword(String userPassword) { if (null == userPassword || userPassword.isEmpty()) { inputLayoutConfirmPassword.setError(getString(R.string.err_msg_password)); showSoftKeyboard(txtInputConfirmPassword); return false; } else { inputLayoutConfirmPassword.setError(null); inputLayoutConfirmPassword.setErrorEnabled(false); } return true; }
void init() { ed_id = (EditText) findViewById(R.id.editText_ID); ed_pw = (EditText) findViewById(R.id.editText_PW); Til_id = (TextInputLayout) findViewById(R.id.Til_id); Til_id.setHint("아이디"); Til_pw = (TextInputLayout) findViewById(R.id.Til_pw); Til_pw.setHint("패스워드"); ed_id.clearFocus(); rel = (RelativeLayout) findViewById(R.id.MainActivityRelativeLayout); rel.requestFocus(); }
public Boolean validationCheck() { if (email.getText().length() == 0) { emailText.setErrorEnabled(true); emailText.setError("Email cannot be left empty"); } else if (password.getText().length() < 6) { passwordText.setErrorEnabled(true); passwordText.setError("Password must be of minimum 6 characters"); } else { return true; } return false; }
private boolean validateFirstName(String firstName) { if (null == firstName || firstName.isEmpty()) { inputLayoutFirstName.setError(getString(R.string.err_msg_first_name)); showSoftKeyboard(txtInputFirstName); return false; } else { inputLayoutLastName.setError(null); inputLayoutFirstName.setErrorEnabled(false); } return true; }
private void getQuestion() { mQuestion.setTitle(topic.getEditText().getText().toString()); mQuestion.setAnswerOne(option_a.getEditText().getText().toString()); if (mQuestion.getQuestionType().equals("choice")) { mQuestion.setAnswerTwo(option_b.getEditText().getText().toString()); mQuestion.setAnswerThree(option_c.getEditText().getText().toString()); mQuestion.setAnswerFour(option_d.getEditText().getText().toString()); } else if (mQuestion.getAnswerOne().equals(getString(R.string.correct))) { mQuestion.setAnswerTwo(getString(R.string.wrong)); } else if (mQuestion.getAnswerOne().equals(getString(R.string.wrong))) { mQuestion.setAnswerTwo(getString(R.string.correct)); } }
/** City validation code */ private boolean validateCity() { final String cityName = cityEditText.getText().toString(); if (cityName.isEmpty()) { cityInputLayout.setError(getString(R.string.enter_city)); requestFocus(cityEditText); return false; } else { cityInputLayout.setErrorEnabled(false); getCityFromServer(cityName); } return true; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); mNameEditTxt = (EditText) findViewById(R.id.register_name_edit_txt); mUsernameEditTxt = (EditText) findViewById(R.id.register_username_edit_txt); mEmailEditTxt = (EditText) findViewById(R.id.register_email_edit_txt); mPasswordEditTxt = (EditText) findViewById(R.id.register_password_edit_txt); mPasswordRepeatEditTxt = (EditText) findViewById(R.id.register_password_repeat_edit_txt); mNameLayout = (TextInputLayout) findViewById(R.id.register_name_layout); mUsernameLayout = (TextInputLayout) findViewById(R.id.register_username_layout); mEmailLayout = (TextInputLayout) findViewById(R.id.register_email_layout); mPasswordLayout = (TextInputLayout) findViewById(R.id.register_password_layout); mPasswordRepeatLayout = (TextInputLayout) findViewById(R.id.register_password_repeat_layout); mRegisterBtn = (Button) findViewById(R.id.register_button); mRegisterLoginBtn = (Button) findViewById(R.id.register_login_btn); autoFill(); initToolbar(); // Work-around to include error text padding mNameLayout.setError(" "); mUsernameLayout.setError(" "); mEmailLayout.setError(" "); mPasswordLayout.setError(" "); mPasswordRepeatLayout.setError(" "); mNameLayout.setError(null); mUsernameLayout.setError(null); mEmailLayout.setError(null); mPasswordLayout.setError(null); mPasswordRepeatLayout.setError(null); mRegisterBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { register(); } }); mRegisterLoginBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { logIn(); } }); }
private void login() { strUsername = username.getEditText().getText().toString(); strPassword = password.getEditText().getText().toString(); mProgressBar.setVisibility(View.VISIBLE); new Thread() { @Override public void run() { result = HttpUtil.sendPostRequest(URL, "username="******"&password=" + strPassword); // Log.i(TAG, result); handler.sendEmptyMessage(0x125); } }.start(); }
private void doLogin() { mAccount = editAccount.getText().toString(); mPassword = editPassword.getText().toString(); if (TextUtils.isEmpty(mAccount)) { textinputAccount.setError(getString(R.string.account_invalid_input_account)); textinputAccount.setErrorEnabled(true); } else if (TextUtils.isEmpty(mPassword)) { textinputPassword.setError(getString(R.string.account_invalid_input_password)); textinputPassword.setErrorEnabled(true); } else { new LoadLoginHtmlTask().execute(); } }
private boolean validateEmail() { String email = EditTextEmailUserValidarEmail.getText().toString().trim(); if (email.isEmpty() || !isValidEmail(email)) { textInputLayoutEmailUserValidarEmail.setError( getString(R.string.err_msg_email)); // cambiar a edittext en register!! requestFocus(EditTextEmailUserValidarEmail); return false; } else { textInputLayoutEmailUserValidarEmail.setErrorEnabled(false); } return true; }
/** kiểm tra có Text, tự set lỗi True: nếu có Text */ public static boolean hasText(TextInputLayout inputLayout, String errorMessage) { // clear error inputLayout.setError(""); inputLayout.setErrorEnabled(false); if (!hasText(inputLayout.getEditText(), errorMessage)) { // Không có text => lỗi inputLayout.setErrorEnabled(true); inputLayout.setError(errorMessage); return false; } return true; }