我在论坛上查看了类似的问题,但它们对解决我的问题没有帮助。
我正在尝试使用以下代码使slidingMenu实现工作:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try{
slidingMenu = new SlidingMenu(this);
slidingMenu.setMode(SlidingMenu.LEFT);
slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
slidingMenu.setShadowWidthRes(R.dimen.slidingmenu_shadow_width);
slidingMenu.setShadowDrawable(R.drawable.abs__ab_bottom_solid_dark_holo);
slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
slidingMenu.setFadeDegree(0.35f);
slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
slidingMenu.setMenu(R.layout.slidemenu);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// getActionBar().setDisplayHomeAsUpEnabled(true);
// }
}catch(Exception e){
Toast.makeText(this, "SlideMenu malfunction!", Toast.LENGTH_LONG).show();
}
}
但我得到以下错误堆栈:
09-25 02:09:23.042: E/AndroidRuntime(7672): FATAL EXCEPTION: main
09-25 02:09:23.042: E/AndroidRuntime(7672): java.lang.NoClassDefFoundError: android.support.v4.view.ViewConfigurationCompat
09-25 02:09:23.042: E/AndroidRuntime(7672): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.initCustomViewAbove(CustomViewAbove.java:167)
09-25 02:09:23.042: E/AndroidRuntime(7672): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.<init>(CustomViewAbove.java:157)
09-25 02:09:23.042: E/AndroidRuntime(7672): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.<init>(CustomViewAbove.java:152)
09-25 02:09:23.042: E/AndroidRuntime(7672): at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:209)
09-25 02:09:23.042: E/AndroidRuntime(7672): at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:192)
09-25 02:09:23.042: E/AndroidRuntime(7672): at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:171)
09-25 02:09:23.042: E/AndroidRuntime(7672): at com.icerge.revivaltimes.MainActivity.onCreate(MainActivity.java:19)
09-25 02:09:23.042: E/AndroidRuntime(7672): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
09-25 02:09:23.042: E/AndroidRuntime(7672): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
09-25 02:09:23.042: E/AndroidRuntime(7672): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
09-25 02:09:23.042: E/AndroidRuntime(7672): at android.app.ActivityThread.access$2300(ActivityThread.java:135)
09-25 02:09:23.042: E/AndroidRuntime(7672): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
09-25 02:09:23.042: E/AndroidRuntime(7672): at android.os.Handler.dispatchMessage(Handler.java:99)
09-25 02:09:23.042: E/AndroidRuntime(7672): at android.os.Looper.loop(Looper.java:144)
09-25 02:09:23.042: E/AndroidRuntime(7672): at android.app.ActivityThread.main(ActivityThread.java:4937)
09-25 02:09:23.042: E/AndroidRuntime(7672): at java.lang.reflect.Method.invokeNative(Native Method)
09-25 02:09:23.042: E/AndroidRuntime(7672): at java.lang.reflect.Method.invoke(Method.java:521)
09-25 02:09:23.042: E/AndroidRuntime(7672): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
09-25 02:09:23.042: E/AndroidRuntime(7672): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
09-25 02:09:23.042: E/AndroidRuntime(7672): at dalvik.system.NativeStart.main(Native Method)
显现:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.icerge.revivaltimes"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
<activity
android:name="com.my.project.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
更新[构建路径错误消息]:
MotionEventCompat cannot be resolved to a variable CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 614 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 600 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 632 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 631 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 636 Java Problem
The constructor SlidingActivityHelper(SlidingFragmentActivity) is undefined SlidingFragmentActivity.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app line 21 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 635 Java Problem
MotionEventCompat cannot be resolved to a variable CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 681 Java Problem
MotionEventCompat cannot be resolved to a variable CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 647 Java Problem
FragmentActivity cannot be resolved to a type SlidingFragmentActivity.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app line 30 Java Problem
FragmentActivity cannot be resolved to a type SlidingFragmentActivity.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app line 11 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 691 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 690 Java Problem
FragmentActivity cannot be resolved to a type SlidingFragmentActivity.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app line 20 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 705 Java Problem
FragmentActivity cannot be resolved to a type SlidingFragmentActivity.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app line 50 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 759 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 760 Java Problem
FragmentActivity cannot be resolved to a type SlidingFragmentActivity.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app line 39 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 736 Java Problem
MotionEventCompat cannot be resolved to a variable CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 758 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 769 Java Problem
FragmentActivity cannot be resolved to a type SlidingFragmentActivity.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app line 75 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 780 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 761 Java Problem
MotionEventCompat cannot be resolved to a variable CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 764 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 838 Java Problem
FragmentActivity cannot be resolved to a type SlidingFragmentActivity.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib/app line 149 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 843 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 783 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 837 Java Problem
KeyEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 944 Java Problem
KeyEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 946 Java Problem
MotionEventCompat cannot be resolved CustomViewAbove.java /slidingmenu/src/com/jeremyfeinstein/slidingmenu/lib line 844 Java Problem