本文整理了Java中com.google.android.material.textfield.TextInputLayout
类的一些代码示例,展示了TextInputLayout
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextInputLayout
类的具体详情如下:
包路径:com.google.android.material.textfield.TextInputLayout
类名称:TextInputLayout
暂无
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
trackersLayout.setErrorEnabled(false);
trackersLayout.setError(null);
}
代码示例来源:origin: TUM-Dev/Campus-Android
private void hideOrShowEmailInput() {
if (includeEmail.isChecked()) {
if (TextUtils.isEmpty(lrzId)) {
customEmailViewLayout.setVisibility(View.VISIBLE);
}
} else {
customEmailViewLayout.setVisibility(View.GONE);
}
}
代码示例来源:origin: michael-rapp/AndroidMaterialDialog
/**
* Adapts the hint of the dialog's edit text widget.
*/
private void adaptHint() {
if (textInputLayout != null) {
textInputLayout.setHint(hint);
} else if (editText != null) {
editText.setHint(hint);
}
}
代码示例来源:origin: proninyaroslav/libretorrent
private void checkEditTextField(CharSequence s)
{
if (TextUtils.isEmpty(s)) {
layoutTorrentName.setErrorEnabled(true);
layoutTorrentName.setError(getString(R.string.error_field_required));
layoutTorrentName.requestFocus();
} else {
layoutTorrentName.setErrorEnabled(false);
layoutTorrentName.setError(null);
}
}
代码示例来源:origin: michael-rapp/AndroidMaterialDialog
/**
* Shows an error text.
*/
private void showErrorText(@Nullable final CharSequence errorText) {
if (textInputLayout != null) {
if (TextUtils.isEmpty(errorText)) {
textInputLayout.setError(null);
textInputLayout.setErrorEnabled(false);
adaptHelperTextColor();
} else {
textInputLayout.setHelperText(null);
textInputLayout.setHelperTextEnabled(false);
textInputLayout.setError(errorText);
textInputLayout.setErrorEnabled(true);
}
}
}
代码示例来源:origin: heinrichreimer/android-issue-reporter
private void setError(TextInputEditText editText, String error) {
try {
View layout = (View) editText.getParent();
while (!layout.getClass().getSimpleName().equals(TextInputLayout.class.getSimpleName()))
layout = (View) layout.getParent();
TextInputLayout realLayout = (TextInputLayout) layout;
realLayout.setError(error);
} catch (ClassCastException | NullPointerException e) {
Log.e(TAG, "Issue while setting error UI.", e);
}
}
代码示例来源:origin: MCMrARM/revolution-irc
@Override
public void bind(BasicEntry entry) {
mName.removeTextChangedListener(mNameTextWatcher);
mName.setText(entry.mName);
mName.addTextChangedListener(mNameTextWatcher);
if (entry.mNameDuplicateError)
mNameCtr.setError(mNameCtr.getResources().getString(R.string.notification_rule_name_collision));
else
mNameCtr.setErrorEnabled(false);
}
代码示例来源:origin: jruesga/rview
private void postUpdateErrorMessage(final Exception cause) {
if (mBinding != null) {
mBinding.repositoryUrl.post(() -> {
final Context context = mBinding.repositoryUrl.getContext();
if (isException(cause, UnsupportedServerVersionException.class)) {
Log.w(TAG, "Gerrit server is unsupported");
mBinding.repositoryUrl.setError(context.getString(
R.string.exception_unsupported_server_version));
} else if (isException(cause, NoConnectivityException.class)) {
mBinding.repositoryUrl.setError(context.getString(
R.string.exception_invalid_endpoint));
代码示例来源:origin: stripe/stripe-android
void adjustViewForPostalCodeAttribute() {
// Set the label/hint to the shorter value if we have three things in a row.
@StringRes final int expiryLabel = mShouldShowPostalCode
? R.string.expiry_label_short
: R.string.acc_label_expiry_date;
mExpiryTextInputLayout.setHint(getResources().getString(expiryLabel));
@IdRes final int focusForward = mShouldShowPostalCode
? R.id.et_add_source_postal_ml
: NO_ID;
mCvcEditText.setNextFocusForwardId(focusForward);
mCvcEditText.setNextFocusDownId(focusForward);
final int postalCodeVisibility = mShouldShowPostalCode ? View.VISIBLE : View.GONE;
mPostalInputLayout.setVisibility(postalCodeVisibility);
// If the postal code field is not shown, the CVC field is the last one in the form and the
// action on the keyboard when the CVC field is focused should be "Done". Otherwise, show
// the "Next" action.
mCvcEditText.setImeOptions(postalCodeVisibility == View.GONE ?
EditorInfo.IME_ACTION_DONE : EditorInfo.IME_ACTION_NEXT);
final int marginPixels = mShouldShowPostalCode
? getResources().getDimensionPixelSize(R.dimen.add_card_expiry_middle_margin)
: 0;
final LinearLayout.LayoutParams linearParams =
(LinearLayout.LayoutParams) mCvcTextInputLayout.getLayoutParams();
linearParams.setMargins(0, 0, marginPixels, 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
linearParams.setMarginEnd(marginPixels);
}
mCvcTextInputLayout.setLayoutParams(linearParams);
}
代码示例来源:origin: jruesga/rview
mBinding.accountUsername.setError(null);
mBinding.accountUsername.clearFocus();
mBinding.accountPassword.setError(null);
mBinding.accountPassword.clearFocus();
mBinding.accessModeSwitcher.requestFocus();
mBinding.setModel(mModel);
代码示例来源:origin: MCMrARM/revolution-irc
@Override
public void afterTextChanged(Editable s) {
getEntry().mNameDuplicateError = false;
mNameCtr.setErrorEnabled(false);
}
}
代码示例来源:origin: jruesga/rview
@Override
public void onCheckedChanged(CompoundButton button, boolean checked) {
mBinding.baseWrapper.setEnabled(checked);
mBinding.baseWrapper.setHintEnabled(checked);
enabledOrDisableButtons();
}
代码示例来源:origin: stripe/stripe-android
@Override
public void setEnabled(boolean enabled) {
mExpiryTextInputLayout.setEnabled(enabled);
mCardNumberTextInputLayout.setEnabled(enabled);
mCvcTextInputLayout.setEnabled(enabled);
mPostalInputLayout.setEnabled(enabled);
mIsEnabled = enabled;
}
代码示例来源:origin: pranavpandey/dynamic-support
/**
* Tint an {@link TextInputLayout} by changing its label and focus colors according to the
* supplied color.
*
* @param textInputLayout The text input layout to be colorized.
* @param color The color to be used.
*/
public static void setColor(@NonNull TextInputLayout textInputLayout, @ColorInt int color) {
try {
Field focusedTextColorField =
TextInputLayout.class.getDeclaredField("focusedTextColor");
focusedTextColorField.setAccessible(true);
focusedTextColorField.set(textInputLayout, ColorStateList.valueOf(color));
Method updateLabelStateMethod = TextInputLayout.class.getDeclaredMethod(
"updateLabelState", boolean.class, boolean.class);
updateLabelStateMethod.setAccessible(true);
updateLabelStateMethod.invoke(textInputLayout, false, true);
} catch (Exception ignored) {
}
if (textInputLayout.getEditText() != null) {
setColor(textInputLayout.getEditText(), color);
}
setHint(textInputLayout, color);
}
代码示例来源:origin: proninyaroslav/libretorrent
private boolean checkUrlField(String s, TextInputLayout layout)
{
if (s == null || layout == null)
return false;
if (TextUtils.isEmpty(s)) {
layout.setErrorEnabled(true);
layout.setError(getString(R.string.error_empty_link));
layout.requestFocus();
return false;
}
layout.setErrorEnabled(false);
layout.setError(null);
return true;
}
代码示例来源:origin: heinrichreimer/android-issue-reporter
private void removeError(TextInputEditText editText) {
try {
View layout = (View) editText.getParent();
while (!layout.getClass().getSimpleName().equals(TextInputLayout.class.getSimpleName()))
layout = (View) layout.getParent();
TextInputLayout realLayout = (TextInputLayout) layout;
realLayout.setError(null);
} catch (ClassCastException | NullPointerException e) {
Log.e(TAG, "Issue while removing error UI.", e);
}
}
代码示例来源:origin: MCMrARM/revolution-irc
@Override
public void afterTextChanged(Editable s) {
if (mMode.getSelectedItemPosition() != MatchEntry.MODE_REGEX ||
MatchEntry.validateRegex(s.toString(), mCaseSensitive.isChecked())) {
mTextCtr.setErrorEnabled(false);
} else {
mTextCtr.setError(mTextCtr.getResources().getString(R.string.notification_rule_regex_invalid));
}
}
代码示例来源:origin: jruesga/rview
private void postUpdateErrorMessage(final Exception cause) {
if (mBinding != null) {
mBinding.accountUsername.post(() -> {
final Context context = mBinding.accountUsername.getContext();
if (isException(cause, UnsupportedServerVersionException.class)) {
R.string.exception_server_connection_issue));
} else {
mBinding.accountUsername.setError(context.getString(
R.string.exception_invalid_user_password));
代码示例来源:origin: MCMrARM/revolution-irc
});
mServerName.addTextChangedListener(new SimpleTextWatcher((Editable s) -> mServerNameCtr.setErrorEnabled(false)));
mServerAddress.addTextChangedListener(new SimpleTextWatcher((Editable s) -> mServerAddressCtr.setErrorEnabled(false)));
mServerPort.addTextChangedListener(new SimpleTextWatcher((Editable s) -> mServerPortCtr.setErrorEnabled(false)));
代码示例来源:origin: jruesga/rview
@Override
public ViewDataBinding inflateView(LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mBinding = DataBindingUtil.inflate(inflater, R.layout.base_chooser_dialog, container, true);
mBinding.changeBase.setOnCheckedChangeListener(this);
// initially 'change parent revision' is unchecked
mBinding.baseWrapper.setEnabled(false);
mBinding.baseWrapper.setHintEnabled(false);
mAdapter = new BaseAdapter(mBinding.getRoot().getContext(),
mLegacyChangeId, mProjectId, mBranch);
return mBinding;
}
内容来源于网络,如有侵权,请联系作者删除!