Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llegalArgumentException when setting error message #122

Open
DCampodonico opened this issue Feb 8, 2018 · 7 comments
Open

llegalArgumentException when setting error message #122

DCampodonico opened this issue Feb 8, 2018 · 7 comments

Comments

@DCampodonico
Copy link

I'm getting this exception if I set an error message in onCreate:

E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.IllegalArgumentException: Layout: -168 < 0
        at android.text.Layout.<init>(Layout.java:215)
        at android.text.StaticLayout.<init>(StaticLayout.java:493)
        at android.text.StaticLayout.<init>(StaticLayout.java:479)
        at android.text.StaticLayout.<init>(StaticLayout.java:457)
        at android.text.StaticLayout.<init>(StaticLayout.java:437)
        at fr.ganfra.materialspinner.MaterialSpinner.prepareBottomPadding(MaterialSpinner.java:380)
        at fr.ganfra.materialspinner.MaterialSpinner.setError(MaterialSpinner.java:760)

Maybe this is happening because the view wasn't completely laid out when calling setError().
A simple workaround is to delay the setError() by some milliseconds, but I don't know how reliable this is on older devices or if it will work everytime.

@chim0380
Copy link

chim0380 commented Oct 30, 2018

same error

@henriquecm
Copy link

I also have been getting this error for sometime.

@kalesonali
Copy link

I am also facing same issue many times. on android os 8.1

@Chivorns
Copy link

Hi you can try with this lib: https://github.com/Chivorns/SmartMaterialSpinner
The problem already fixed in this lib.
Good luck.

@novas1r1
Copy link

novas1r1 commented Aug 6, 2019

Still having this issue

@chim0380
Copy link

chim0380 commented Aug 6, 2019

This error can occur when setError() is called during a lifecycle Activity/Fragment , rather than a user action. For example if you call setError onStart, on Resume. Spinner can't draw and measure correctly. I solved this error by calling setError in handler.postDelayed()

@Chivorns
Copy link

Hi @novas1r1 , have you tried https://github.com/Chivorns/SmartMaterialSpinner yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants