.initSlideMode throws an IllegalArgumentException
Closed this issue · 4 comments
I have 2 views, 0th view for menu; 1st view for dynamic content according what user has clicked(ExpandableListView.handleItemClick) in the menu:
protected void open(View view) {
mRoot.removeViewAt(1);
mRoot.addView(view);
mRoot.close();
}
It throws an exception:
06-26 21:18:05.454: E/AndroidRuntime(11351): java.lang.IllegalArgumentException: width and height must be > 0
06-26 21:18:05.454: E/AndroidRuntime(11351): at android.graphics.Bitmap.createBitmap(Bitmap.java:603)
06-26 21:18:05.454: E/AndroidRuntime(11351): at android.graphics.Bitmap.createBitmap(Bitmap.java:585)
06-26 21:18:05.454: E/AndroidRuntime(11351): at com.agimind.widget.SlideHolder.initSlideMode(SlideHolder.java:565)
06-26 21:18:05.454: E/AndroidRuntime(11351): at com.agimind.widget.SlideHolder.close(SlideHolder.java:258)
06-26 21:18:05.454: E/AndroidRuntime(11351): at com.xuehuar.newtech.ui.DesktopActivity.open(DesktopActivity.java:76)
06-26 21:18:05.454: E/AndroidRuntime(11351): at com.xuehuar.newtech.ui.DesktopActivity$1.onChangeView(DesktopActivity.java:63)
06-26 21:18:05.454: E/AndroidRuntime(11351): at com.xuehuar.newtech.desktop.Desktop$2.onChildClick(Desktop.java:125)
06-26 21:18:05.454: E/AndroidRuntime(11351): at android.widget.ExpandableListView.handleItemClick(ExpandableListView.java:582)
06-26 21:18:05.454: E/AndroidRuntime(11351): at android.widget.ExpandableListView.performItemClick(ExpandableListView.java:521)
06-26 21:18:05.454: E/AndroidRuntime(11351): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
06-26 21:18:05.454: E/AndroidRuntime(11351): at android.widget.AbsListView$1.run(AbsListView.java:3168)
06-26 21:18:05.454: E/AndroidRuntime(11351): at android.os.Handler.handleCallback(Handler.java:605)
06-26 21:18:05.454: E/AndroidRuntime(11351): at android.os.Handler.dispatchMessage(Handler.java:92)
06-26 21:18:05.454: E/AndroidRuntime(11351): at android.os.Looper.loop(Looper.java:137)
06-26 21:18:05.454: E/AndroidRuntime(11351): at android.app.ActivityThread.main(ActivityThread.java:4424)
06-26 21:18:05.454: E/AndroidRuntime(11351): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 21:18:05.454: E/AndroidRuntime(11351): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 21:18:05.454: E/AndroidRuntime(11351): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-26 21:18:05.454: E/AndroidRuntime(11351): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-26 21:18:05.454: E/AndroidRuntime(11351): at dalvik.system.NativeStart.main(Native Method)
@raywill SlideHolder wasn't designed for swaping views "on the fly". It's better to use Fragments for such situations or keep 1st view as a container for other views and add\remove views from it (instead of SlideHolder directly).
Seems that we are in similar timezone ;-)
I just figured out why it fails. When I call addView, I missed the layout params and then it turns out that the width and height is zero.
Should use:
LayoutParams contentParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
mRoot.addView(mContent.getView(), contentParams );
So, this is not an issue. plz close it.
You are right. Even if I added layout params, it still crash ;-(
I will do it in the way "keep 1st view as a container for other views and add\remove views from it (instead of SlideHolder directly)."
Are you going to fix this?
FYI, I'm facing on the same problems. In my case, LinearLayout is okay but FrameLayout's creating bitmap function make the same Error.