本文整理汇总了Java中android.widget.TextView.setError方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setError方法的具体用法?Java TextView.setError怎么用?Java TextView.setError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addGesture
import android.widget.TextView; //导入方法依赖的package包/类
@SuppressWarnings({"UnusedDeclaration"})
public void addGesture(View v) {
if (mGesture != null) {
final TextView input = (TextView) findViewById(R.id.gesture_name);
final CharSequence name = input.getText();
if (name.length() == 0) {
input.setError(getString(R.string.error_missing_name));
return;
}
final GestureLibrary store = GestureBuilderActivity.getStore();
store.addGesture(name.toString(), mGesture);
store.save();
setResult(RESULT_OK);
final String path = new File(Environment.getExternalStorageDirectory(),
"gestures").getAbsolutePath();
Toast.makeText(this, getString(R.string.save_success, path), Toast.LENGTH_LONG).show();
} else {
setResult(RESULT_CANCELED);
}
finish();
}
示例2: validateId
import android.widget.TextView; //导入方法依赖的package包/类
protected ValidationResult validateId(String dataString, View ui, int textViewId) {
TextView textView = (TextView) ui.findViewById(textViewId);
if (TextUtils.isEmpty(dataString)) {
textView.setError(null);
return new ValidationResult(textView, ValidationResult.Validity.UNKNOWN);
} else {
if (dataString.length() != 6) {
textView.setError("Please type in 6 digits ID");
return new ValidationResult(textView, ValidationResult.Validity.ERROR);
}
try {
Integer.parseInt(dataString);
} catch (Throwable t) {
textView.setError("Please type in 6 digits ID");
return new ValidationResult(textView, ValidationResult.Validity.ERROR);
}
textView.setError(null);
return new ValidationResult(textView, ValidationResult.Validity.VALID);
}
}
示例3: validateZip
import android.widget.TextView; //导入方法依赖的package包/类
protected ValidationResult validateZip(String dataString, View ui, int textViewId) {
TextView textView = (TextView) ui.findViewById(textViewId);
if (TextUtils.isEmpty(dataString)) {
textView.setError(null);
return new ValidationResult(textView, ValidationResult.Validity.UNKNOWN);
} else {
if (dataString.length() != 5) {
textView.setError("Please type in 5 digit ZIP code");
return new ValidationResult(textView, ValidationResult.Validity.ERROR);
}
try {
Integer.parseInt(dataString);
} catch (Throwable t) {
textView.setError("Please type in 5 digit ZIP code");
return new ValidationResult(textView, ValidationResult.Validity.ERROR);
}
textView.setError(null);
return new ValidationResult(textView, ValidationResult.Validity.VALID);
}
}
示例4: checkEmptyField
import android.widget.TextView; //导入方法依赖的package包/类
/**
* Check if the the textview is empty
*
* @param ctx Current context
* @param view Le Current TextView
*/
public static void checkEmptyField(Context ctx, TextView view) {
if (view.getText().toString().trim().length() == 0) {
view.setError(view.getResources().getString(R.string.empty_field));
} else {
view.setError(null);
}
}
示例5: setTotal
import android.widget.TextView; //导入方法依赖的package包/类
public void setTotal(TextView totalText, Total total) {
if (total.isError()) {
setTotalError(totalText);
} else {
setAmountText(totalText, total);
totalText.setError(null);
}
}
示例6: addAmountAndErrorNode
import android.widget.TextView; //导入方法依赖的package包/类
private void addAmountAndErrorNode(Total total) {
TextView data = x.addInfoNode(layout, -1, R.string.not_available, "");
Drawable dr = getResources().getDrawable(R.drawable.total_error);
dr.setBounds(0, 0, dr.getIntrinsicWidth(), dr.getIntrinsicHeight());
if (total.currency == Currency.EMPTY) {
data.setText(R.string.currency_make_default_warning);
} else {
data.setText(total.getError(AbstractTotalsDetailsActivity.this));
}
data.setError("Error!", dr);
}
示例7: setError
import android.widget.TextView; //导入方法依赖的package包/类
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);
}
}
示例8: setTotalError
import android.widget.TextView; //导入方法依赖的package包/类
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);
}
示例9: onClick
import android.widget.TextView; //导入方法依赖的package包/类
public void onClick(View v) {
v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
switch (v.getId()) {
case R.id.fragment_forgot_password_submit:
boolean validForm = true;
TextView forgotEmail = (TextView) getActivity().findViewById(R.id.fragment_forgot_password_email_address);
if (forgotEmail .getText().length() == 0) {
forgotEmail.setError("Please enter your e-mail address.");
forgotEmail.requestFocus();
validForm = false;
} else if (!android.util.Patterns.EMAIL_ADDRESS.matcher(forgotEmail.getText()).matches()) {
forgotEmail.setError("Please enter valid e-mail address.");
forgotEmail.requestFocus();
validForm = false;
}
if (validForm) {
InputMethodManager inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(forgotEmail.getWindowToken(), 0);
mResetPassTask = new ResetPasswordTask().execute(new String[]{forgotEmail.getText().toString()});
}
break;
}
}