Android 6 EditText.setError not working correctly
Asked Answered
S

3

12

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

enter image description here

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?

Seiler answered 13/3, 2016 at 1:37 Comment(4)
I haven't used that library, but it looks like a theme/style issue.Sancha
Try the validation without that library and see if it still doesn't work. I've seen this issue, but I think it was on Android 4.4 and 4.3 - never on Marshmallow or Lollipop.Scrivener
I'm also having the same issue on android 5.1 and 6.0 and I'm not using any plugin for validation. This works fine on android 4.4 for me.Emikoemil
Hi, this issue isn't related to the library.Heparin
P
2

use getString(R.string.error_name)

Pillowcase answered 3/5, 2016 at 6:37 Comment(1)
But the question shows messageResId - getString(...) will not return a resource identifier but the actual string, and it seems the library wants a resource identifier.Kymric
E
1

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);
Elanorelapid answered 3/5, 2016 at 23:48 Comment(0)
A
1

TRY @NotEmpty annotation on Email edittext field

@NotEmpty
@Email
private EditText email;
Acie answered 4/5, 2016 at 5:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.