android.widget.TextView#setError ( )源码实例Demo

下面列出了android.widget.TextView#setError ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: medical-data-android   文件: TestActivity.java
/**
 * 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;
}
 
源代码2 项目: financisto   文件: Utils.java
public void setTotal(TextView totalText, Total total) {
    if (total.isError()) {
        setTotalError(totalText);
    } else {
        setAmountText(totalText, total);
        totalText.setError(null);
    }
}
 
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);
}
 
源代码4 项目: data-binding-validator   文件: EditTextHandler.java
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);
    }
}
 
源代码5 项目: memoir   文件: LinkFragment.java
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);
    }
}
 
源代码6 项目: medical-data-android   文件: TestActivity.java
/**
 * 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;
}
 
源代码7 项目: pretixdroid   文件: QuestionDialogHelper.java
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));
    }

}
 
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;
    }
}
 
源代码9 项目: Android-RTEditor   文件: LinkFragment.java
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);
    }
}
 
源代码10 项目: openwebnet-android   文件: IpcamActivity.java
protected boolean isValidUrl(TextView view) {
    if (view != null && !URLUtil.isValidUrl(editTextIpcamUrl.getText().toString())) {
        view.setError(validationUrl);
        view.requestFocus();
        return false;
    }
    return true;
}
 
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;
}
 
源代码12 项目: financisto   文件: Utils.java
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);
}
 
源代码13 项目: Pioneer   文件: ViewUtils.java
public static void setError(TextView view, CharSequence error) {
    view.setError(Texts.withColor(error, Color.RED));
}
 
源代码14 项目: medic-gateway   文件: SettingsDialogActivity.java
private void showError(int componentId, int stringId) {
	TextView field = (TextView) findViewById(componentId);
	field.setError(getString(stringId));
}
 
源代码15 项目: medic-gateway   文件: ComposeSmsActivity.java
private void showError(int componentId, int stringId) {
	TextView field = (TextView) findViewById(componentId);
	field.setError(getString(stringId));
}
 
源代码16 项目: Pioneer   文件: ViewUtils.java
public static void setError(TextView view, CharSequence error) {
    view.setError(Texts.withColor(error, Color.RED));
}
 
源代码17 项目: hawkular-android-client   文件: LoginActivity.java
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;

    }
 
源代码18 项目: medic-android   文件: SettingsDialogActivity.java
private void showError(int componentId, int stringId) {
	TextView field = (TextView) findViewById(componentId);
	field.setError(getString(stringId));
}
 
源代码19 项目: medical-data-android   文件: ProfileActivity.java
/**
 * 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);
}
 
源代码20 项目: medical-data-android   文件: RegisterActivity.java
/**
 * 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);
}
 
 方法所在类
 同类方法