Java Code Examples for android.support.design.widget.TextInputLayout#setError()
The following examples show how to use
android.support.design.widget.TextInputLayout#setError() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddFoodFragment.java From privacy-friendly-food-tracker with GNU General Public License v3.0 | 6 votes |
private void showErrorMessage(View view, int errorMessageId){ // reset error messages ((TextInputLayout)referenceActivity.findViewById(R.id.inputFoodName)).setError(""); ((TextInputLayout)referenceActivity.findViewById(R.id.inputCalories)).setError(""); ((TextInputLayout)referenceActivity.findViewById(R.id.inputFoodAmount)).setError(""); // if the view that this is called on is a TextInputlayout, we can show the error on the TextinputLayout if(view instanceof TextInputLayout){ TextInputLayout til = (TextInputLayout) view; til.setError(getString(errorMessageId)); } else { //otherwise show a generic error message Snackbar.make(view, errorMessageId, Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }
Example 2
Source File: ValidationUtils.java From q-municate-android with Apache License 2.0 | 6 votes |
public boolean isFullNameValid(TextInputLayout fullNameTextInputLayout, String newFullName) { boolean fullNameEntered = !TextUtils.isEmpty(newFullName.trim()); boolean valid = true; if (fullNameEntered) { if (newFullName.length() < FULL_NAME_MIN_LENGTH) { valid = false; fullNameTextInputLayout.setError(context.getString(R.string.auth_full_name_field_is_too_short)); } else if (newFullName.length() > FULL_NAME_MAX_LENGTH) { valid = false; fullNameTextInputLayout.setError(context.getString(R.string.auth_full_name_field_is_too_long)); } } else { valid = false; fullNameTextInputLayout.setError(context.getString(R.string.profile_full_name_not_entered)); } return valid; }
Example 3
Source File: FeedbackDialog.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
@Override public void afterTextChanged(Editable s) { TextInputLayout et = weakEt.get(); if (StringUtils.validate(s.toString())) { if (et != null) et.setErrorEnabled(false); return; } if (et != null) { et.setErrorEnabled(true); et.setError(PalmApp.getContext().getString(R.string.illegal_email_format)); } }
Example 4
Source File: ValidationUtils.java From q-municate-android with Apache License 2.0 | 5 votes |
public boolean isForgotPasswordDataValid(TextInputLayout emailTextInputLayout, String email) { boolean isEmailEntered = !TextUtils.isEmpty(email.trim()); if (isEmailEntered) { if (!isEmailValid(email)) { emailTextInputLayout.setError(context.getString(R.string.forgot_password_email_field_is_incorrect)); } else { return true; } } else { emailTextInputLayout.setError(context.getString(R.string.forgot_password_email_field_not_entered)); } return false; }
Example 5
Source File: EditDeviceActivity.java From AndroidSDK with MIT License | 5 votes |
private boolean checkInput(TextInputLayout textInputLayout, int errorResId) { String text = textInputLayout.getEditText().getText().toString(); if (TextUtils.isEmpty(text)) { textInputLayout.setError(getResources().getString(errorResId)); textInputLayout.requestFocus(); return false; } return true; }
Example 6
Source File: AddDeviceActivity.java From AndroidSDK with MIT License | 5 votes |
private boolean checkInput(TextInputLayout textInputLayout, int errorResId) { String text = textInputLayout.getEditText().getText().toString(); if (TextUtils.isEmpty(text)) { textInputLayout.setError(getResources().getString(errorResId)); textInputLayout.requestFocus(); return false; } return true; }
Example 7
Source File: AddDataStreamActivity.java From AndroidSDK with MIT License | 5 votes |
private boolean checkInput(TextInputLayout textInputLayout, int errorResId) { String text = textInputLayout.getEditText().getText().toString(); if (TextUtils.isEmpty(text)) { textInputLayout.setError(getResources().getString(errorResId)); textInputLayout.requestFocus(); return false; } return true; }
Example 8
Source File: DataBindingConverters.java From mv2m with Apache License 2.0 | 5 votes |
@BindingAdapter({"app:error"}) public static void bindValidationError(TextInputLayout textInputLayout, int errorRes) { if (errorRes != 0) { textInputLayout.setError(textInputLayout.getResources().getString(errorRes)); } else { textInputLayout.setError(null); } }
Example 9
Source File: ValidationUtils.java From q-municate-android with Apache License 2.0 | 5 votes |
public boolean isChangePasswordDataValid(TextInputLayout oldPasswordTextInputLayout, TextInputLayout newPasswordTextInputLayout, String oldPassword, String newPassword) { boolean isOldPasswordEntered = !TextUtils.isEmpty(oldPassword.trim()); boolean isNewPasswordEntered = !TextUtils.isEmpty(newPassword.trim()); if (isOldPasswordEntered && isNewPasswordEntered) { if (!qbUser.getPassword().equals(oldPassword)) { oldPasswordTextInputLayout.setError(context.getString(R.string.change_password_old_password_wrong)); } else { return true; } } else if (!isOldPasswordEntered && !isNewPasswordEntered) { oldPasswordTextInputLayout.setError(context.getString(R.string.change_password_all_fields_not_entered)); newPasswordTextInputLayout.setError(context.getString(R.string.change_password_all_fields_not_entered)); } else { if (!isOldPasswordEntered) { oldPasswordTextInputLayout .setError(context.getString(R.string.change_password_old_password_not_entered)); } if (!isNewPasswordEntered) { newPasswordTextInputLayout .setError(context.getString(R.string.change_password_new_password_not_entered)); } } return false; }
Example 10
Source File: ValidationUtils.java From q-municate-android with Apache License 2.0 | 5 votes |
public boolean isLoginDataValid(TextInputLayout emailTextInputLayout, TextInputLayout passwordTextInputLayout, String email, String password) { boolean isEmailEntered = !TextUtils.isEmpty(email.trim()); boolean isPasswordEntered = !TextUtils.isEmpty(password.trim()); if (isEmailEntered && isPasswordEntered) { boolean valid = true; if (!isEmailValid(email)) { valid = false; emailTextInputLayout.setError(context.getString(R.string.auth_email_field_is_incorrect)); } if (password.length() < PASSWORD_MIN_LENGTH) { valid = false; passwordTextInputLayout.setError(context.getString(R.string.auth_password_field_is_too_short)); } return valid; } else if (!isEmailEntered && !isPasswordEntered) { emailTextInputLayout.setError(context.getString(R.string.auth_not_all_fields_entered)); passwordTextInputLayout.setError(context.getString(R.string.auth_not_all_fields_entered)); } else { if (!isEmailEntered) { emailTextInputLayout.setError(context.getString(R.string.auth_email_field_not_entered)); } if (!isPasswordEntered) { passwordTextInputLayout.setError(context.getString(R.string.auth_password_field_not_entered)); } } return false; }
Example 11
Source File: EnrollActivity.java From Android-Bluetooth-Fingerprint with Apache License 2.0 | 5 votes |
private boolean validateInput(EditText EdTxt, TextInputLayout inputLayout) { if (EdTxt.getText().toString().trim().isEmpty()) { inputLayout.setError(getString(R.string.err_msg_input)); requestFocus(EdTxt); return false; } else { inputLayout.setErrorEnabled(false); } return true; }
Example 12
Source File: TextInputLayoutValidator.java From AwesomeValidation with MIT License | 5 votes |
@Override public void halt() { for (ValidationHolder validationHolder : mValidationHolderList) { if (validationHolder.isSomeSortOfView()) { validationHolder.resetCustomError(); } else { TextInputLayout textInputLayout = validationHolder.getTextInputLayout(); textInputLayout.setErrorEnabled(false); textInputLayout.setError(null); } } }
Example 13
Source File: TextInputLayoutValidator.java From AwesomeValidation with MIT License | 5 votes |
@Override public void execute(ValidationHolder validationHolder, Matcher matcher) { TextInputLayout textInputLayout = validationHolder.getTextInputLayout(); textInputLayout.setErrorTextAppearance(mErrorTextAppearance); textInputLayout.setErrorEnabled(true); textInputLayout.setError(validationHolder.getErrMsg()); }
Example 14
Source File: GittyReporter.java From GittyReporter with Apache License 2.0 | 5 votes |
private void setError(TextView view, String text) { TextInputLayout parent = (TextInputLayout) view.getParent(); // there is a small flashing when the error is set again // the only way to fix that is to track if the error is // currently shown, because for some reason TextInputLayout // doesn't provide any getError methods. parent.setError(text); }
Example 15
Source File: SubmitGankActivity.java From GankGirl with GNU Lesser General Public License v2.1 | 4 votes |
private void setError(TextInputEditText editText, @StringRes int errorRes) { TextInputLayout layout = (TextInputLayout) editText.getParent().getParent(); layout.setError(getString(errorRes)); }
Example 16
Source File: LoginActivity.java From meiShi with Apache License 2.0 | 4 votes |
private void setEditTextError(TextInputLayout layout, int msgId) { layout.setErrorEnabled(true); layout.setError(getString(msgId)); }
Example 17
Source File: DataBindingAdapters.java From OpenYOLO-Android with Apache License 2.0 | 4 votes |
/** * Facilitates binding error text to a TextInputLayout. */ @BindingAdapter("errorText") public static void setErrorText(TextInputLayout layout, String errorText) { layout.setError(errorText); }
Example 18
Source File: BugReportActivity.java From Orin with GNU General Public License v3.0 | 4 votes |
private void removeError(TextInputEditText editText) { TextInputLayout layout = (TextInputLayout) editText.getParent(); layout.setError(null); }
Example 19
Source File: BugReportActivity.java From Orin with GNU General Public License v3.0 | 4 votes |
private void setError(TextInputEditText editText, @StringRes int errorRes) { TextInputLayout layout = (TextInputLayout) editText.getParent(); layout.setError(getString(errorRes)); }
Example 20
Source File: SignUpActivity.java From meiShi with Apache License 2.0 | 4 votes |
private void setEditTextError(TextInputLayout layout, int msgId) { layout.setErrorEnabled(true); layout.setError(getString(msgId)); }