MaterialSpinner
MaterialSpinner copied to clipboard
llegalArgumentException when setting error message
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.
same error
I also have been getting this error for sometime.
I am also facing same issue many times. on android os 8.1
Hi you can try with this lib: https://github.com/Chivorns/SmartMaterialSpinner The problem already fixed in this lib. Good luck.
Still having this issue
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()
Hi @novas1r1 , have you tried https://github.com/Chivorns/SmartMaterialSpinner yet?