本文整理了Java中com.google.android.material.textfield.TextInputLayout.setError()
方法的一些代码示例,展示了TextInputLayout.setError()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextInputLayout.setError()
方法的具体详情如下:
包路径:com.google.android.material.textfield.TextInputLayout
类名称:TextInputLayout
方法名:setError
暂无
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
trackersLayout.setErrorEnabled(false);
trackersLayout.setError(null);
}
代码示例来源: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: proninyaroslav/libretorrent
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
webSeedsLayout.setErrorEnabled(false);
webSeedsLayout.setError(null);
}
代码示例来源: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: proninyaroslav/libretorrent
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
urlFieldLayout.setErrorEnabled(false);
urlFieldLayout.setError(null);
}
代码示例来源:origin: mlykotom/valifi
/**
* Error binding for TextInputLayout
*
* @param view TextInputLayout to be set with
* @param errorMessage error message to show
*/
@BindingAdapter("error")
public static void setError(TextInputLayout view, String errorMessage) {
view.setError(errorMessage);
}
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
filterFieldLayout.setErrorEnabled(false);
filterFieldLayout.setError(null);
}
代码示例来源:origin: heinrichreimer/android-issue-reporter
private void setError(TextInputEditText editText, @StringRes int errorRes) {
try {
View layout = (View) editText.getParent();
while (!layout.getClass().getSimpleName().equals(TextInputLayout.class.getSimpleName()))
layout = (View) layout.getParent();
TextInputLayout realLayout = (TextInputLayout) layout;
realLayout.setError(getString(errorRes));
} catch (ClassCastException | NullPointerException e) {
Log.e(TAG, "Issue while setting error UI.", e);
}
}
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
fileNameLayout.setErrorEnabled(false);
fileNameLayout.setError(null);
}
代码示例来源:origin: jruesga/rview
public void onViewValidated(View v, Validator failed) {
TextInputLayout layout = getTextInputLayoutFromView(v);
if (layout != null) {
layout.setError(failed == null ? null : failed.getMessage());
}
}
代码示例来源:origin: proninyaroslav/libretorrent
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
fieldLayout.setErrorEnabled(false);
fieldLayout.setError(null);
}
代码示例来源:origin: jruesga/rview
public void onViewValidated(View v, Validator failed) {
TextInputLayout layout = getTextInputLayoutFromView(v);
if (layout != null) {
layout.setError(failed == null ? null : failed.getMessage());
}
}
代码示例来源:origin: stripe/stripe-android
@Override
public void displayErrorMessage(@Nullable String message) {
if (message == null) {
textInputLayout.setErrorEnabled(false);
} else {
textInputLayout.setError(message);
}
}
}
代码示例来源:origin: WireGuard/wireguard-android
private void createTunnelAndDismiss() {
if (binding != null) {
final String name = binding.tunnelNameText.getText().toString();
Application.getTunnelManager().create(name, config).whenComplete((tunnel, throwable) -> {
if (tunnel != null) {
dismiss();
} else {
binding.tunnelNameTextLayout.setError(throwable.getMessage());
}
});
}
}
代码示例来源: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: Ilhasoft/data-binding-validator
public static void setError(TextView textView, String errorMessage) {
TextInputLayout textInputLayout = getTextInputLayout(textView);
if (textInputLayout != null) {
textInputLayout.setErrorEnabled(!TextUtils.isEmpty(errorMessage));
textInputLayout.setError(errorMessage);
} else {
textView.setError(errorMessage);
}
}
代码示例来源: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: WellingtonCosta/convalida
public static void setError(EditText editText, String errorMessage) {
TextInputLayout layout = getTextInputLayout(editText);
if (layout != null) {
layout.setErrorEnabled(errorMessage != null);
layout.setError(errorMessage);
} else {
editText.setError(errorMessage);
}
}
代码示例来源: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: proninyaroslav/libretorrent
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
fieldLayout.setErrorEnabled(false);
fieldLayout.setError(null);
/* Clear selection of invalid url */
Spannable text = field.getText();
ForegroundColorSpan[] errorSpans = text.getSpans(0, text.length(),
ForegroundColorSpan.class);
for (ForegroundColorSpan span : errorSpans) {
text.removeSpan(span);
}
}
内容来源于网络,如有侵权,请联系作者删除!