是否可以在一项活动中附加超过 2 个 SlidingMenu 对象?由不同的按钮触发?
我的计划是有一个底部操作栏,所以我在屏幕的所有 4 个角落都有按钮。我希望它们中的每一个都能触发或切换具有不同内容的不同 SlidingMenu。
我已经有了前 2 个,但是我缺少后 2 个,因为当我尝试实例化它们时我没有错误,错误是当我.setMenu()
在最后 2 个(底部)中调用方法时。
我打算做什么,可能吗?如果是,我该如何实现?
sMenuLeft = new SlidingMenu(this);
sMenuLeft.setMode(SlidingMenu.LEFT_RIGHT);
sMenuLeft.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
sMenuLeft.setShadowWidthRes(R.dimen.shadow_width);
sMenuLeft.setShadowDrawable(R.drawable.shadow);
sMenuLeft.setBehindOffsetRes(R.dimen.slidingmenu_100_offset);
sMenuLeft.setFadeEnabled(false);
sMenuLeft.setBehindScrollScale(0.0f);
sMenuLeft.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
sMenuLeft.setMenu(foo);
sMenuLeft.setSecondaryMenu(foo2);
sMenuRight = new SlidingMenu(this);
sMenuRight.setMode(SlidingMenu.LEFT_RIGHT);
sMenuRight.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
sMenuRight.setShadowWidthRes(R.dimen.shadow_width);
sMenuRight.setShadowDrawable(R.drawable.shadow_right);
sMenuRight.setBehindOffsetRes(R.dimen.slidingmenu_50_offset);
sMenuRight.setFadeEnabled(false);
sMenuRight.setBehindScrollScale(0.0f);
sMenuRight.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
sMenuRight.setMenu(foo3); // Error is here
sMenuRight.setSecondaryMenu(foo4); // And I suppose here as well
更新:
LogCat 显示:
07-19 19:15:29.203: E/AndroidRuntime(30038): FATAL EXCEPTION: main
07-19 19:15:29.203: E/AndroidRuntime(30038): java.lang.RuntimeException: Unable to start activity ComponentInfo{co.aktio.moveo/co.aktio.moveo.android.MapsActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2049)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2083)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.app.ActivityThread.access$600(ActivityThread.java:134)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1233)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.os.Handler.dispatchMessage(Handler.java:99)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.os.Looper.loop(Looper.java:137)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.app.ActivityThread.main(ActivityThread.java:4722)
07-19 19:15:29.203: E/AndroidRuntime(30038): at java.lang.reflect.Method.invokeNative(Native Method)
07-19 19:15:29.203: E/AndroidRuntime(30038): at java.lang.reflect.Method.invoke(Method.java:511)
07-19 19:15:29.203: E/AndroidRuntime(30038): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
07-19 19:15:29.203: E/AndroidRuntime(30038): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
07-19 19:15:29.203: E/AndroidRuntime(30038): at dalvik.system.NativeStart.main(Native Method)
07-19 19:15:29.203: E/AndroidRuntime(30038): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-19 19:15:29.203: E/AndroidRuntime(30038): at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.setMenu(SlidingMenu.java:370)
07-19 19:15:29.203: E/AndroidRuntime(30038): at co.aktio.moveo.android.MapsActivity.onCreate(MapsActivity.java:140)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.app.Activity.performCreate(Activity.java:4539)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2013)
07-19 19:15:29.203: E/AndroidRuntime(30038): ... 11 more
07-19 19:15:29.203: E/AndroidRuntime(30038): Caused by: java.lang.ClassNotFoundException: android.view.fragment
07-19 19:15:29.203: E/AndroidRuntime(30038): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-19 19:15:29.203: E/AndroidRuntime(30038): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-19 19:15:29.203: E/AndroidRuntime(30038): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:636)
07-19 19:15:29.203: E/AndroidRuntime(30038): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
07-19 19:15:29.203: E/AndroidRuntime(30038): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
07-19 19:15:29.203: E/AndroidRuntime(30038): ... 19 more