Android 6 EditText.setError not working correctly

只谈情不闲聊 提交于 2019-12-04 17:40:26

问题


I have upgraded to android 6 and seeing some strange things when trying to set validation for some editTexts. I am using android-saripaar for validation:

@Email(messageResId = R.string.error_email)
private EditText email;
@Password(min = 6, scheme = Password.Scheme.ALPHA_NUMERIC_MIXED_CASE_SYMBOLS)
private EditText password;
@ConfirmPassword
private EditText repassword;
@NotEmpty(messageResId = R.string.error_name)
private EditText firstname;
@NotEmpty(messageResId = R.string.error_name)
private EditText lastname;
private Validator mValidator;

For some reason the email, password, confirm password are not showing the error message on the popup, while the last and first name are fine

I have tried without the library and the same issue occurred. Using editText.setError("Some Message") This did not happen prior to android 6 and was working fine on 5.

Anybody experienced similar to this? if so how did you fix it?


回答1:


use getString(R.string.error_name)




回答2:


TRY @NotEmpty annotation on Email edittext field

@NotEmpty
@Email
private EditText email;



回答3:


i think this is related to activity theme, this what i'm using and working in android 6.0:

activity theme :

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

code : please note i'm extending activity not AppCompatActivity

myeditText.setError("Please enter valid email");
myeditText.setFocusable(true);


来源:https://stackoverflow.com/questions/35965466/android-6-edittext-seterror-not-working-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!