本文整理匯總了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;
}
}