I’m trying to use SlidingTray.
But adding the example into my view it gives NullPointerException in SlidingTray.onLayout().
Testing on Android 4.1.
Stack:
09-29 01:31:06.840: E/AndroidRuntime(8905): FATAL EXCEPTION: main
09-29 01:31:06.840: E/AndroidRuntime(8905): java.lang.NullPointerException
09-29 01:31:06.840: E/AndroidRuntime(8905): at com.sileria.android.view.SlidingTray.onLayout(Unknown Source)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.View.layout(View.java:11359)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.ViewGroup.layout(ViewGroup.java:4571)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:925)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.View.layout(View.java:11359)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.ViewGroup.layout(ViewGroup.java:4571)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.View.layout(View.java:11359)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.ViewGroup.layout(ViewGroup.java:4571)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.View.layout(View.java:11359)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.ViewGroup.layout(ViewGroup.java:4571)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.View.layout(View.java:11359)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.ViewGroup.layout(ViewGroup.java:4571)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.View.layout(View.java:11359)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.ViewGroup.layout(ViewGroup.java:4571)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1665)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2700)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.os.Handler.dispatchMessage(Handler.java:99)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.os.Looper.loop(Looper.java:156)
09-29 01:31:06.840: E/AndroidRuntime(8905): at android.app.ActivityThread.main(ActivityThread.java:5045)
Any ideas why I am seeing this exception?
I’ve been using this library for a while now, and got stuck with this same error. Since i turned the project into an android library project instead of just using the jar, i was able to detect where was the error.
On line 455 there is
switch (mHandlePos) {here is the nullpointer.Looking on the code, there’s a setter for this mHandlePos, so all i did was calling this setter and i was good to go. Check it out:
I think the developer forgot to set the default position of the handler in the constructor. Well, calling the
setHandlePositionworked for me without having to change the source code.