Java Code Examples for android.widget.TextView#setError()
The following examples show how to use
android.widget.TextView#setError() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestActivity.java From medical-data-android with GNU General Public License v3.0 | 8 votes |
/** * Auxiliar function to get questions 8 to 10 value and set an error if they have not been * answered. * * @param i Number of question * @param id {@link RatingStars} id * @param text {@link TextView} id of the question title * @param error {@link TextView} title of the first question title whose question has an error * @return <code>true</code> if an error was set; <code>false</code> otherwise. */ private TextView NumberPickerAnswered(int i, int id, int text, TextView error) { NumberPicker np = (NumberPicker) findViewById(id); int value = np.getValue(); TextView tv = (TextView) findViewById(text); if (value == 0) { tv.setError(""); if (error == null) { return tv; } } else { questions[i] = ((i == 7) ? (value - 1) * 10 : (value - 1)); tv.setError(null); } return error; }
Example 2
Source File: Utils.java From financisto with GNU General Public License v2.0 | 5 votes |
public void setTotal(TextView totalText, Total total) { if (total.isError()) { setTotalError(totalText); } else { setAmountText(totalText, total); totalText.setError(null); } }
Example 3
Source File: AbstractTotalsDetailsActivity.java From financisto with GNU General Public License v2.0 | 5 votes |
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); }
Example 4
Source File: EditTextHandler.java From data-binding-validator with Apache License 2.0 | 5 votes |
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); } }
Example 5
Source File: AbstractDeviceActivity.java From openwebnet-android with MIT License | 5 votes |
protected boolean isValidRequired(TextView view) { if (utilityService.isBlankText(view) || view.getText().equals(labelNone) || view.getText().equals(labelMissingGateway)) { view.setError(validationRequired); view.requestFocus(); return false; } return true; }
Example 6
Source File: LinkFragment.java From memoir with Apache License 2.0 | 5 votes |
private void validate(Dialog dialog, TextView addressView, TextView textView) { // retrieve link address and do some cleanup final String address = addressView.getText().toString().trim(); boolean isEmail = sEmailValidator.isValid(address); boolean isUrl = sUrlValidator.isValid(address); if (requiredFieldValid(addressView) && (isUrl || isEmail)) { // valid url or email address // encode address String newAddress = Helper.encodeQuery(address); // add mailto: for email addresses if (isEmail && !startsWithMailto(newAddress)) { newAddress = "mailto:" + newAddress; } // use the original address text as link text if the user didn't enter anything String linkText = textView.getText().toString(); if (linkText.length() == 0) { linkText = address; } EventBus.getDefault().post(new LinkEvent(LinkFragment.this, new Link(linkText, newAddress), false)); try { dialog.dismiss(); } catch (Exception ignore) {} } else { // invalid address (neither a url nor an email address String errorMessage = getString(R.string.rte_invalid_link, address); addressView.setError(errorMessage); } }
Example 7
Source File: IpcamActivity.java From openwebnet-android with MIT License | 5 votes |
protected boolean isValidUrl(TextView view) { if (view != null && !URLUtil.isValidUrl(editTextIpcamUrl.getText().toString())) { view.setError(validationUrl); view.requestFocus(); return false; } return true; }
Example 8
Source File: LinkFragment.java From Android-RTEditor with Apache License 2.0 | 5 votes |
private void validate(DialogInterface dialog, TextView addressView, TextView textView) { // retrieve link address and do some cleanup final String address = addressView.getText().toString().trim(); boolean isEmail = sEmailValidator.isValid(address); boolean isUrl = sUrlValidator.isValid(address); if (requiredFieldValid(addressView) && (isUrl || isEmail)) { // valid url or email address // encode address String newAddress = Helper.encodeUrl(address); // add mailto: for email addresses if (isEmail && !startsWithMailto(newAddress)) { newAddress = "mailto:" + newAddress; } // use the original address text as link text if the user didn't enter anything String linkText = textView.getText().toString(); if (linkText.length() == 0) { linkText = address; } EventBus.getDefault().post(new LinkEvent(LinkFragment.this, new Link(linkText, newAddress), false)); try { dialog.dismiss(); } catch (Exception ignore) {} } else { // invalid address (neither a url nor an email address String errorMessage = getString(R.string.rte_invalid_link, address); addressView.setError(errorMessage); } }
Example 9
Source File: TestActivity.java From medical-data-android with GNU General Public License v3.0 | 5 votes |
/** * Auxiliar function to get questions 1 to 6 value and set an error if they have not been * answered. * * @param i Number of question * @param rating {@link RatingStars} id * @param text {@link TextView} id of the question title * @param error {@link TextView} title of the first question title whose question has an error * @return <code>true</code> if an error was set; <code>false</code> otherwise. */ private TextView RatingStarsAnswered(int i, int rating, int text, TextView error) { RatingStars r = (RatingStars) findViewById(rating); questions[i] = r.getAnswer(); TextView tv = (TextView) findViewById(text); if (questions[i] == 10) { // default value is 10 tv.setError(""); if (error == null) return tv; } else { tv.setError(null); } return error; }
Example 10
Source File: QuestionDialogHelper.java From pretixdroid with GNU General Public License v3.0 | 5 votes |
public static void addError(Context ctx, Object f, TextView label, int strid) { if (f instanceof EditText) { ((EditText) f).setError(strid == 0 ? null : ctx.getString(strid)); } else if (f instanceof List && ((List) f).get(0) instanceof EditText) { ((List<EditText>) f).get(1).setError(strid == 0 ? null : ctx.getString(strid)); } else if (label != null) { label.setError(strid == 0 ? null : ctx.getString(strid)); } }
Example 11
Source File: AndroidMessageDisplay.java From NextInputs-Android with Apache License 2.0 | 5 votes |
static boolean setErrorMessageOnTextView(View inputView, String message){ if (TextView.class.isAssignableFrom(inputView.getClass())) { final TextView text = (TextView) inputView; text.setError(message); return true; } else { return false; } }
Example 12
Source File: SettingsDialogActivity.java From medic-android with GNU Affero General Public License v3.0 | 4 votes |
private void showError(int componentId, int stringId) { TextView field = (TextView) findViewById(componentId); field.setError(getString(stringId)); }
Example 13
Source File: LoginActivity.java From hawkular-android-client with Apache License 2.0 | 4 votes |
private boolean validForm() { boolean check = true; TextView[] fields = new TextView[] {mHost, mUsername, mPassword}; for (TextView field : fields) { if(field.getText().toString().trim().isEmpty()) { field.setError(getString(R.string.cannot_be_blank)); check = false; } } return check; }
Example 14
Source File: ViewUtils.java From Pioneer with Apache License 2.0 | 4 votes |
public static void setError(TextView view, CharSequence error) { view.setError(Texts.withColor(error, Color.RED)); }
Example 15
Source File: ComposeSmsActivity.java From medic-gateway with GNU Affero General Public License v3.0 | 4 votes |
private void showError(int componentId, int stringId) { TextView field = (TextView) findViewById(componentId); field.setError(getString(stringId)); }
Example 16
Source File: SettingsDialogActivity.java From medic-gateway with GNU Affero General Public License v3.0 | 4 votes |
private void showError(int componentId, int stringId) { TextView field = (TextView) findViewById(componentId); field.setError(getString(stringId)); }
Example 17
Source File: ViewUtils.java From Pioneer with Apache License 2.0 | 4 votes |
public static void setError(TextView view, CharSequence error) { view.setError(Texts.withColor(error, Color.RED)); }
Example 18
Source File: Utils.java From financisto with GNU General Public License v2.0 | 4 votes |
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); }
Example 19
Source File: RegisterActivity.java From medical-data-android with GNU General Public License v3.0 | 2 votes |
/** * Eliminate the error on terms and conditions {@link TextView} if the terms and conditions * {@link CheckBox} is clicked. * * @param view * @see TextView#setError(CharSequence) */ public void onCheckboxClicked(View view) { TextView terms_error = (TextView) findViewById(R.id.terms_text); terms_error.setError(null); }
Example 20
Source File: ProfileActivity.java From medical-data-android with GNU General Public License v3.0 | 2 votes |
/** * Eliminate the error on terms and conditions {@link TextView} if the terms and conditions * {@link CheckBox} is clicked. * * @param view * @see TextView#setError(CharSequence) */ public void onCheckboxClicked(View view) { TextView terms_error = (TextView) findViewById(R.id.terms_text); terms_error.setError(null); }