-
Notifications
You must be signed in to change notification settings - Fork 81
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
NullPointerException when adding values programmatically by setValues() #38
Comments
Experiencing the same problem. I reckon this is on the snapshot release. |
@dakshsrivastava You can try my fork, I'm sure I've fixed this issue. |
@devslava Did just that. Took a checkout of your work. Got it working. Thanks a ton! 👍 |
Hello, I have used gradle plugin to use this, all is working fine but when I am going to add it dynamically by using setValues its crashing and giving me error like Caused by: java.lang.IllegalArgumentException: Layout: -12 < 0, please help me out. |
I got library by compile 'com.wefika:horizontal-picker:1.1.1'. But I have this problem yet. How to get last version of Lib |
@pratikdasa @AkbarBegimqulov Try my fork. Download or clone and compile it. https://github.com/devslava/HorizontalPicker/tree/issues_37_38 |
@devslava I have integrated updated library, error is solved, but now, when I am setting the sideItems value to 2 then its crashing with same error. Error line is in setValues method : layouts[i] = new BoringLayout(this.values[i], textPaint, itemWidth, Layout.Alignment.ALIGN_CENTER, Here itemWidth is creating problem. As before I have set static value 12 instead of itemWidth, it was working but now its crashing while sideItems value to 2. Please check and let me know. |
@devslava |
In your example I added a button which sets values to HorizontalPicker by setValues() method.
When it is clicked, app crashes with NullPointerException
java.lang.NullPointerException at android.text.BoringLayout.getLineStart(BoringLayout.java:345) at android.text.Layout.getLineEnd(Layout.java:1130) at android.text.Layout.getLineExtent(Layout.java:955) at android.text.Layout.getLineWidth(Layout.java:942) at com.wefika.horizontalpicker.HorizontalPicker.onDraw(HorizontalPicker.java:281) at android.view.View.draw(View.java:14486) at android.view.View.getDisplayList(View.java:13383) at android.view.View.getDisplayList(View.java:13425) at android.view.View.draw(View.java:14203) at android.view.ViewGroup.drawChild(ViewGroup.java:3103) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940) at android.view.View.getDisplayList(View.java:13378) at android.view.View.getDisplayList(View.java:13425) at android.view.View.draw(View.java:14203) at android.view.ViewGroup.drawChild(ViewGroup.java:3103) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940) at android.view.View.getDisplayList(View.java:13378) at android.view.View.getDisplayList(View.java:13425) at android.view.View.draw(View.java:14203) at android.view.ViewGroup.drawChild(ViewGroup.java:3103) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940) at android.view.View.getDisplayList(View.java:13378) at android.view.View.getDisplayList(View.java:13425) at android.view.View.draw(View.java:14203) at android.view.ViewGroup.drawChild(ViewGroup.java:3103) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940) at android.view.View.draw(View.java:14489) at android.widget.FrameLayout.draw(FrameLayout.java:472) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2327) at android.view.View.getDisplayList(View.java:13383) at android.view.View.getDisplayList(View.java:13425) at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1571) at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1450) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2409) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2281) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1892) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1005) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5750) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) at android.view.Choreographer.doCallbacks(Choreographer.java:574) at android.view.Choreographer.doFrame(Choreographer.java:544) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method)
If HorizontalPicker had GONE visibility, and by button click I add values and then make it visible, it crashes with another exception.
java.lang.IllegalArgumentException: Layout: -8 < 0 at android.text.Layout.<init>(Layout.java:138) at android.text.Layout.<init>(Layout.java:114) at android.text.BoringLayout.<init>(BoringLayout.java:145) at com.wefika.horizontalpicker.HorizontalPicker.setValues(HorizontalPicker.java:698) at com.wefika.horizontalpicker.example.MainActivity$1.onClick(MainActivity.java:53) at android.view.View.performClick(View.java:4443) at android.view.View$PerformClick.run(View.java:18443) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method)
The text was updated successfully, but these errors were encountered: