android.support.design.widget.TextInputLayout#setErrorEnabled ( )源码实例Demo

下面列出了android.support.design.widget.TextInputLayout#setErrorEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openshop.io-android   文件: Utils.java
/**
 * Method checks if text input layout exist and contains some value.
 * If layout is empty, then show error value under the textInputLayout.
 *
 * @param textInputLayout textInputFiled for check.
 * @param errorValue      value displayed when ext input is empty.
 * @return true if everything ok.
 */
public static boolean checkTextInputLayoutValueRequirement(TextInputLayout textInputLayout, String errorValue) {
    if (textInputLayout != null && textInputLayout.getEditText() != null) {
        String text = Utils.getTextFromInputLayout(textInputLayout);
        if (text == null || text.isEmpty()) {
            textInputLayout.setErrorEnabled(true);
            textInputLayout.setError(errorValue);
            Timber.d("Input field %s missing text.", textInputLayout.getHint());
            return false;
        } else {
            textInputLayout.setErrorEnabled(false);
            Timber.d("Input field: %s OK.", textInputLayout.getHint());
            return true;
        }
    } else {
        Timber.e(new RuntimeException(), "Checking null input field during order send.");
        return false;
    }
}
 
源代码2 项目: OmniList   文件: FeedbackDialog.java
@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));
    }
}
 
源代码3 项目: Musicoco   文件: TextInputHelper.java
public static void textInputErrorTwinkle(TextInputLayout il, String str) {
    String error = (String) il.getError();
    if (TextUtils.isEmpty(error)) {
        error = TextUtils.isEmpty(str) ? "!" : str;
    }

    il.setErrorEnabled(false);
    il.setError(error);
    il.setErrorEnabled(true);
}
 
源代码4 项目: africastalking-android   文件: Cuhn.java
private void disableAllFields() {
    TextInputLayout allFields[] = {pinInputLayout, cvvInputLayout, cardNumber, expiryInputLayout};
    for (TextInputLayout field : allFields) {
        field.setEnabled(false);
        field.setErrorEnabled(false);
    }
    Arrays.fill(allFields, null);
}
 
源代码5 项目: Luhn   文件: Luhn.java
private void disableAllFields() {
    TextInputLayout allFields[] = {pinInputLayout, cvvInputLayout, cardNumber, expiryInputLayout};
    for (TextInputLayout field : allFields) {
        field.setEnabled(false);
        field.setErrorEnabled(false);
    }
    Arrays.fill(allFields, null);

}
 
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;
}
 
/** Called when the activity is first created */
@Override
public void onCreate(Bundle savedInstanceState) {
  SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
  if (preferences.getBoolean(AuthenticatorActivity.KEY_DARK_MODE_ENABLED, false)) {
    setTheme(R.style.AuthenticatorTheme_NoActionBar_Dark);
  } else {
    setTheme(R.style.AuthenticatorTheme_NoActionBar);
  }

  super.onCreate(savedInstanceState);
  setContentView(R.layout.enter_key);

  setSupportActionBar((Toolbar) findViewById(R.id.enter_key_toolbar));
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  getSupportActionBar().setDisplayShowHomeEnabled(true);

  // Find all the views on the page
  keyEntryField = (EditText) findViewById(R.id.key_value);
  accountName = (EditText) findViewById(R.id.account_name);
  keyEntryFieldInputLayout = (TextInputLayout) findViewById(R.id.key_value_input_layout);

  typeTotp = (RadioButton) findViewById(R.id.type_choice_totp);
  typeHotp = (RadioButton) findViewById(R.id.type_choice_hotp);

  typeTotp.setText(getResources().getStringArray(R.array.type)[OtpType.TOTP.value]);
  typeHotp.setText(getResources().getStringArray(R.array.type)[OtpType.HOTP.value]);

  keyEntryFieldInputLayout.setErrorEnabled(true);

  // Set listeners
  keyEntryField.addTextChangedListener(this);

  findViewById(R.id.add_account_button_enter_key)
      .setOnClickListener(addButtonEnterKeyOnClickListener);
}
 
@Override
public void execute(ValidationHolder validationHolder, Matcher matcher) {
    TextInputLayout textInputLayout = validationHolder.getTextInputLayout();
    textInputLayout.setErrorTextAppearance(mErrorTextAppearance);
    textInputLayout.setErrorEnabled(true);
    textInputLayout.setError(validationHolder.getErrMsg());
}
 
@Override
public void halt() {
    for (ValidationHolder validationHolder : mValidationHolderList) {
        if (validationHolder.isSomeSortOfView()) {
            validationHolder.resetCustomError();
        } else {
            TextInputLayout textInputLayout = validationHolder.getTextInputLayout();
            textInputLayout.setErrorEnabled(false);
            textInputLayout.setError(null);
        }
    }
}
 
源代码10 项目: SuperNote   文件: FolderPresenter.java
private void setEditError(int position, String errorTip) {
    TextInputLayout textInputLayout=(TextInputLayout)mAdapter.getViewByPosition(position,R.id.textinput_edit_folder_name);
    textInputLayout.setErrorEnabled(true);
    textInputLayout.setError(errorTip);
}
 
源代码11 项目: openshop.io-android   文件: LoginDialogFragment.java
/**
 * Check if editTexts are valid view and if user set all required fields.
 *
 * @return true if ok.
 */
private boolean isRequiredFields(TextInputLayout emailWrapper, TextInputLayout passwordWrapper) {
    if (emailWrapper == null || passwordWrapper == null) {
        Timber.e(new RuntimeException(), "Called isRequiredFields with null parameters.");
        MsgUtils.showToast(getActivity(), MsgUtils.TOAST_TYPE_INTERNAL_ERROR, null, MsgUtils.ToastLength.LONG);
        return false;
    } else {
        EditText email = emailWrapper.getEditText();
        EditText password = passwordWrapper.getEditText();
        if (email == null || password == null) {
            Timber.e(new RuntimeException(), "Called isRequiredFields with null editTexts in wrappers.");
            MsgUtils.showToast(getActivity(), MsgUtils.TOAST_TYPE_INTERNAL_ERROR, null, MsgUtils.ToastLength.LONG);
            return false;
        } else {
            boolean isEmail = false;
            boolean isPassword = false;

            if (email.getText().toString().equalsIgnoreCase("")) {
                emailWrapper.setErrorEnabled(true);
                emailWrapper.setError(getString(R.string.Required_field));
            } else {
                emailWrapper.setErrorEnabled(false);
                isEmail = true;
            }

            if (password.getText().toString().equalsIgnoreCase("")) {
                passwordWrapper.setErrorEnabled(true);
                passwordWrapper.setError(getString(R.string.Required_field));
            } else {
                passwordWrapper.setErrorEnabled(false);
                isPassword = true;
            }

            if (isEmail && isPassword) {
                return true;
            } else {
                Timber.e("Some fields are required.");
                return false;
            }
        }
    }
}
 
源代码12 项目: meiShi   文件: SignUpActivity.java
private void setEditTextError(TextInputLayout layout, int msgId) {
    layout.setErrorEnabled(true);
    layout.setError(getString(msgId));
}
 
源代码13 项目: meiShi   文件: ResetPasswordActivity.java
private void setEditTextError(TextInputLayout layout, int msgId) {
    layout.setErrorEnabled(true);
    layout.setError(getString(msgId));
}
 
源代码14 项目: meiShi   文件: LoginActivity.java
private void setEditTextError(TextInputLayout layout, int msgId) {
    layout.setErrorEnabled(true);
    layout.setError(getString(msgId));
}