本文整理了Java中android.widget.TextView.setError()
方法的一些代码示例,展示了TextView.setError()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setError()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setError
暂无
代码示例来源:origin: stackoverflow.com
protected void onPause () {
TextView textView = ...; // fetch it as appropriate
textView.setError(null);
}
代码示例来源:origin: stackoverflow.com
TextView errorText = (TextView)mySpinner.getSelectedView();
errorText.setError("anything here, just to add the icon");
errorText.setTextColor(Color.RED);//just to highlight that this is an error
errorText.setText("my actual error text");//changes the selected item text to this
代码示例来源:origin: stackoverflow.com
TextView errorText = (TextView)mySpinner.getSelectedView();
errorText.setError("");
errorText.setTextColor(Color.RED);//just to highlight that this is an error
errorText.setText("my actual error text");//changes the selected item text to this
代码示例来源:origin: stackoverflow.com
public void onValidationFailed(View failedView, Rule<?> failedRule) {
if (failedView instanceof Checkable) {
Toast.makeText(this, failedRule.getFailureMessage(), Toast.LENGTH_SHORT).show();
} else if (failedView instanceof TextView) {
TextView view = (TextView) failedView;
view.requestFocus();
view.setError(failedRule.getFailureMessage());
}
}
代码示例来源:origin: ZieIony/Carbon
@CheckResult
@NonNull
default Consumer<? super Integer> errorRes() {
return (Consumer<Integer>) textRes -> ((android.widget.TextView) this).setError(((android.widget.TextView) this).getContext().getResources().getText(textRes));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testGetError() {
assertNull(textView.getError());
CharSequence error = "myError";
textView.setError(error);
assertEquals(error, textView.getError());
}
代码示例来源:origin: stackoverflow.com
public void setError(View v, CharSequence s) {
TextView name = (TextView) v.findViewById(R.id.name);
name.setError(s);
}
代码示例来源:origin: stackoverflow.com
View selectedView = spinner.getSelectedView();
if (selectedView != null && selectedView instanceof TextView) {
TextView selectedTextView = (TextView) selectedView;
if (!valid) {
String errorString = selectedTextView.getResources().getString(mErrorStringResource);
selectedTextView.setError(errorString);
}
else {
selectedTextView.setError(null);
}
}
代码示例来源:origin: thyrlian/AwesomeValidation
@Override
public void reset(ValidationHolder validationHolder) {
TextView textViewError = (TextView) ((Spinner) validationHolder.getView()).getSelectedView();
textViewError.setError(null);
textViewError.setTextColor(Color.BLACK);
}
}, R.string.err_tech_stacks);
代码示例来源:origin: thyrlian/AwesomeValidation
@Override
public void execute(ValidationHolder validationHolder) {
TextView textViewError = (TextView) ((Spinner) validationHolder.getView()).getSelectedView();
textViewError.setError(validationHolder.getErrMsg());
textViewError.setTextColor(Color.RED);
}
}, new CustomErrorReset() {
代码示例来源:origin: stackoverflow.com
static public void setSpinnerError(Spinner spinner, String error){
View selectedView = spinner.getSelectedView();
if (selectedView != null && selectedView instanceof TextView) {
TextView selectedTextView = (TextView) selectedView;
selectedTextView.setError(error);
}
}
代码示例来源:origin: stackoverflow.com
for(int i=0;i< listData.length;i++){
if(listData[i]==updatedlistData[i]){
View v=listView.getChildAt(i);
TextView tv=(TextView) v.findViewById(android.R.id.text1);
tv.setError("Please change the data");
}
}
代码示例来源:origin: stackoverflow.com
for(int i = 0; i<listview.getCount(); i++){
TextView tv = ((View)listview.getViewByPosition(i, listview)).findViewById(R.id.textView);
if(tv.getText().toString().length() == 0){
tv.setError("This is required");
}
}
代码示例来源:origin: alexfu/form-validator
@Override public void onFieldValidated(ValidationResult result) {
if (result.isValid()) {
result.view.setError(null);
} else {
result.view.setError(result.errors.get(0));
validationErrors.add(result);
}
}
代码示例来源:origin: dsolonenko/financisto
private void setTotalError(TextView totalText) {
totalText.setText(R.string.not_available);
Drawable dr = context.getResources().getDrawable(R.drawable.total_error);
dr.setBounds(0, 0, dr.getIntrinsicWidth(), dr.getIntrinsicHeight());
totalText.setError(totalText.getText(), dr);
}
代码示例来源:origin: lijy91/blankapp-validation
@Override
public void onValid(List<Rule> rules) {
for (Rule rule : rules) {
((TextView) rule.view()).setError(null, null);
}
}
代码示例来源:origin: nurkiewicz/rxjava-book-examples
@Override public void call(CharSequence text) {
view.setError(text);
}
};
代码示例来源: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: dsolonenko/financisto
public void setTotal(TextView totalText, Total total) {
if (total.isError()) {
setTotalError(totalText);
} else {
setAmountText(totalText, total);
totalText.setError(null);
}
}
代码示例来源:origin: dsolonenko/financisto
@Override
public boolean validateState() {
if (Utils.isEmpty(repeatWeeksEditText)) {
repeatWeeksEditText.setError(activity.getString(R.string.specify_value));
return false;
}
if (days.isEmpty()) {
daysOfWeekText.setError(activity.getString(R.string.specify_value));
return false;
}
return true;
}
内容来源于网络,如有侵权,请联系作者删除!