当前位置: 首页>>代码示例>>Java>>正文


Java EditText.setError方法代码示例

本文整理汇总了Java中android.widget.EditText.setError方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.setError方法的具体用法?Java EditText.setError怎么用?Java EditText.setError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.EditText的用法示例。


在下文中一共展示了EditText.setError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attemptLogin

import android.widget.EditText; //导入方法依赖的package包/类
private void attemptLogin() {
    EditText password_edit = (EditText) findViewById(R.id.pin_login_password);

    // Reset errors.
    password_edit.setError(null);

    // Store values at the time of the login attempt.
    String password = password_edit.getText().toString();

    // Check for a valid password, if the user entered one.
    if (TextUtils.isEmpty(password)) {
        password_edit.setError(getString(R.string.error_field_required));
        password_edit.requestFocus();
    } else {
        // Show a progress spinner, and kick off a background task to
        // perform the user login attempt.
        showProgress(true);
        new ProfilePinLoginActivity.PinLoginTask(password).execute((Void) null);
    }
}
 
开发者ID:gbizzotto,项目名称:dapay,代码行数:21,代码来源:ProfilePinLoginActivity.java

示例2: onInput

import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
    if (mIsFirstTextChanged) {
        mIsFirstTextChanged = false;
        return;
    }
    EditText editText = dialog.getInputEditText();
    if (editText == null)
        return;
    int errorResId = 0;
    if (input == null || input.length() == 0) {
        errorResId = R.string.text_name_should_not_be_empty;
    } else if (!input.equals(mExcluded)) {
        if (new File(getCurrentDirectory(), mExtension == null ? input.toString() : input.toString() + mExtension).exists()) {
            errorResId = R.string.text_file_exists;
        }
    }
    if (errorResId == 0) {
        editText.setError(null);
        dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
    } else {
        editText.setError(getString(errorResId));
        dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
    }

}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:27,代码来源:ScriptOperations.java

示例3: isValid

import android.widget.EditText; //导入方法依赖的package包/类
public static boolean isValid(EditText editText, String regex, String errMsg, boolean required) {

        String text = editText.getText().toString().trim();
        // clearing the error, if it was previously set by some other values
        editText.setError(null);

        // text required and editText is blank, so return false
        if (required && !hasText(editText)) return false;

        // pattern doesn't match so returning false
        if (required && !Pattern.matches(regex, text)) {
            editText.setError(errMsg);
            return false;
        }
        ;

        return true;
    }
 
开发者ID:QuixomTech,项目名称:DeviceInfo,代码行数:19,代码来源:Validation.java

示例4: isEnteredTextValid

import android.widget.EditText; //导入方法依赖的package包/类
private static boolean isEnteredTextValid(Context context, EditText editText, int resFieldName, int maxLength, boolean checkName) {

        boolean isCorrect;
        Pattern p;
        if (checkName) {
            p = Pattern.compile("^[a-zA-Z][a-zA-Z 0-9]{2," + (maxLength - 1) + "}+$");
        } else {
            p = Pattern.compile("^[a-zA-Z][a-zA-Z0-9]{2," + (maxLength - 1) + "}+$");
        }

        Matcher m = p.matcher(editText.getText().toString().trim());
        isCorrect = m.matches();

        if (!isCorrect) {
            editText.setError(String.format(context.getString(R.string.error_name_must_not_contain_special_characters_from_app),
                    context.getString(resFieldName),
                    maxLength));
            return false;
        } else {
            return true;
        }
    }
 
开发者ID:mobilemaster128,项目名称:quickblox-android,代码行数:23,代码来源:ValidationUtils.java

示例5: redirectUserToAuthorizeAndLogin

import android.widget.EditText; //导入方法依赖的package包/类
private void redirectUserToAuthorizeAndLogin(EditText editText) {
    /* To authorize this app and log in it's necessary to redirect to the domain given,
     * activity_login there, and the server will redirect back to the app with its response. */
    String endpoint = MastodonApi.ENDPOINT_AUTHORIZE;
    String redirectUri = getOauthRedirectUri();
    Map<String, String> parameters = new HashMap<>();
    parameters.put("client_id", clientId);
    parameters.put("redirect_uri", redirectUri);
    parameters.put("response_type", "code");
    parameters.put("scope", OAUTH_SCOPES);
    String url = "https://" + domain + endpoint + "?" + toQueryString(parameters);
    Uri uri = Uri.parse(url);
    if (!openInCustomTab(uri, this)) {
        Intent viewIntent = new Intent(Intent.ACTION_VIEW, uri);
        if (viewIntent.resolveActivity(getPackageManager()) != null) {
            startActivity(viewIntent);
        } else {
            editText.setError(getString(R.string.error_no_web_browser_found));
        }
    }
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:22,代码来源:LoginActivity.java

示例6: checkPasswordsMatch

import android.widget.EditText; //导入方法依赖的package包/类
private void checkPasswordsMatch( final EditText mPasswordConfirmText ) {
    // Check if passwords match
    if (!StringValidator.checkPasswords(tempPass, tempPassConfirm)) {
        errorFlag = true;
        mPasswordConfirmText.setError(getString(R.string.sign_up_non_matching_passwords));
        mPasswordConfirmText.requestFocus();
    } else
        mPasswordConfirmText.setError(null);
}
 
开发者ID:chrisqz95,项目名称:couch-potatoes,代码行数:10,代码来源:SignUpActivity.java

示例7: checkEmptyText

import android.widget.EditText; //导入方法依赖的package包/类
private boolean checkEmptyText(EditText txt) {
    if(TextUtils.isEmpty(txt.getText().toString())) {
        txt.setError("Empty");
        return false;
    }
    txt.setError(null);
    return true;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:9,代码来源:MondotalkCreate.java

示例8: checkValidFirstName

import android.widget.EditText; //导入方法依赖的package包/类
private void checkValidFirstName( final EditText mFirstNameText ) {
    // Check first name for valid alpha and non empty
    if (tempFirstName.isEmpty()){
        errorFlag = true;
        mFirstNameText.setError(getString(R.string.sign_up_missing_name));
    } else if (!StringValidator.isAlpha(tempFirstName)){
        errorFlag = true;
        mFirstNameText.setError(getString(R.string.sign_up_invalid_name));
    } else
        mFirstNameText.setError(null);
}
 
开发者ID:chrisqz95,项目名称:couch-potatoes,代码行数:12,代码来源:SignUpActivity.java

示例9: validate

import android.widget.EditText; //导入方法依赖的package包/类
boolean validate(EditText editText) {
    if (editText.getText().toString().length() == 0) {
        editText.setError("Field Required");
        editText.requestFocus();
    }
    return editText.getText().toString().length() > 0;
}
 
开发者ID:androidmads,项目名称:SQLite2XL,代码行数:8,代码来源:SQLite2ExcelActivity.java

示例10: onPostExecute

import android.widget.EditText; //导入方法依赖的package包/类
@Override
protected void onPostExecute(final Boolean success) {
    EditText password_edit = (EditText) findViewById(R.id.pin_login_password);
    if (success) {
        Intent intent = new Intent(ProfilePinLoginActivity.this, MainActivity.class);
        startActivity(intent);
        showProgress(false);
    } else {
        showProgress(false);
        if (mLoginError == IExchangeAPI.ErrorOrPayload.ERROR_NONE) {
            password_edit.setError(getString(R.string.error_no_response));
            password_edit.requestFocus();
        } else {
            switch (mLoginError) {
                case IExchangeAPI.ErrorOrPayload.ERROR_NOT_CONNECTED:
                    password_edit.setError(getString(R.string.error_no_connectivity));
                    password_edit.requestFocus();
                    break;
                case IExchangeAPI.ErrorOrPayload.ERROR_LOGIN_PASS:
                    password_edit.setError(getString(R.string.error_incorrect_password));
                    password_edit.requestFocus();
                    break;
                case IExchangeAPI.ErrorOrPayload.ERROR_UNAUTHORIZED:
                    password_edit.setError(getString(R.string.error_unauthorized));
                    password_edit.requestFocus();
                    break;
                case IExchangeAPI.ErrorOrPayload.ERROR_UNKNOWN:
                    password_edit.setError(getString(R.string.error_unknown));
                    password_edit.requestFocus();
                    break;
            }
        }
    }
}
 
开发者ID:gbizzotto,项目名称:dapay,代码行数:35,代码来源:ProfilePinLoginActivity.java

示例11: checkValidMiddleName

import android.widget.EditText; //导入方法依赖的package包/类
private void checkValidMiddleName( final EditText mMiddleNameText ) {
    // Check middle name for valid alpha
    if (!StringValidator.isAlpha(tempMiddleName) && !tempMiddleName.isEmpty()){
        errorFlag = true;
        mMiddleNameText.setError(getString(R.string.sign_up_invalid_name));
    } else
        mMiddleNameText.setError(null);
}
 
开发者ID:chrisqz95,项目名称:couch-potatoes,代码行数:9,代码来源:SignUpActivity.java

示例12: onNextButtonClick

import android.widget.EditText; //导入方法依赖的package包/类
@ActionHandler(layoutResource = R.id.next_button)
public void onNextButtonClick(View v){
    EditText passwordEditText       = (EditText)findViewById(R.id.password);
    EditText passwordConfirm1       = (EditText)findViewById(R.id.password_confirm);
    EditText usernameEdit           = (EditText)findViewById(R.id.username_edittext);

    String errorMessageLength       = "password length should be greater than 3";
    String errorMessageMatch        = "password does not match";
    CharSequence sequence           = passwordEditText.getText();
    CharSequence sequenceConfirm    = passwordConfirm1.getText();

    if(usernameEdit.getText().toString().length()<1){
        usernameEdit.setError("Please give me your name");
        return;
    }
    mUserName=usernameEdit.getText().toString();
    if(isValidPassword(sequence)){
        if(sequence.toString().equals(sequenceConfirm.toString())) {
            mUserSecretDatabase=sequence.toString();
                Boolean permission=checkPermissions();
                if(permission){
                    new DatabaseSetupTask().execute();
                }

            }else{
                passwordConfirm1.setError(errorMessageMatch);
            }
        }else{
            passwordEditText.setError(errorMessageLength);
        }

}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:33,代码来源:InitActivity.java

示例13: isFieldEmpty

import android.widget.EditText; //导入方法依赖的package包/类
private boolean isFieldEmpty(EditText formField) {
    if (TextUtils.isEmpty(formField.getText().toString())) {
        formField.setError(getString(R.string.error_field_required));
        return true;
    }
    return false;
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:8,代码来源:CreateAccountActivity.java

示例14: checkEditText

import android.widget.EditText; //导入方法依赖的package包/类
public static boolean checkEditText(EditText editText, String name, boolean required, int length) {
	String text = text(editText);
	if (isEmpty(text) && required) {
		editText.setError("Please specify the "+name+"..");
		return false;
	}
	if (text != null && text.length() > length) {
		editText.setError("Length of the "+name+" must not be more than "+length+" chars..");
		return false;
	}
	return true;
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:13,代码来源:Utils.java

示例15: checkInvalidPassword

import android.widget.EditText; //导入方法依赖的package包/类
private void checkInvalidPassword( final EditText mPasswordText ) {
    // Check if password is invalid
    if (!StringValidator.isValidPassword(tempPass)) {
        errorFlag = true;
        mPasswordText.setError(getString(R.string.sign_up_invalid_password));
        mPasswordText.requestFocus();
    } else
        mPasswordText.setError(null);
}
 
开发者ID:chrisqz95,项目名称:couch-potatoes,代码行数:10,代码来源:SignUpActivity.java


注:本文中的android.widget.EditText.setError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。