我有一个应用程序,其中有一个滑动菜单。我已经使用 jfeinstein 的库实现了它。直到昨天它工作得很好,但现在它已经停止工作了。我什至没有对代码进行任何更改。这是错误报告:
08-20 15:02:52.060: E/AndroidRuntime(32366): FATAL EXCEPTION: main
08-20 15:02:52.060: E/AndroidRuntime(32366): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cvapp/com.cvapp.SecondActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread.access$600(ActivityThread.java:140)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.os.Handler.dispatchMessage(Handler.java:99)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.os.Looper.loop(Looper.java:137)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread.main(ActivityThread.java:4898)
08-20 15:02:52.060: E/AndroidRuntime(32366): at java.lang.reflect.Method.invokeNative(Native Method)
08-20 15:02:52.060: E/AndroidRuntime(32366): at java.lang.reflect.Method.invoke(Method.java:511)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
08-20 15:02:52.060: E/AndroidRuntime(32366): at dalvik.system.NativeStart.main(Native Method)
08-20 15:02:52.060: E/AndroidRuntime(32366): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityHelper.onCreate(SlidingActivityHelper.java:45)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivity.onCreate(SlidingActivity.java:22)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.cvapp.SecondActivity.onCreate(SecondActivity.java:19)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.Activity.performCreate(Activity.java:5206)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
08-20 15:02:52.060: E/AndroidRuntime(32366): ... 11 more
08-20 15:02:52.060: E/AndroidRuntime(32366): Caused by: java.lang.reflect.InvocationTargetException
08-20 15:02:52.060: E/AndroidRuntime(32366): at java.lang.reflect.Constructor.constructNative(Native Method)
08-20 15:02:52.060: E/AndroidRuntime(32366): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-20 15:02:52.060: E/AndroidRuntime(32366): ... 21 more
08-20 15:02:52.060: E/AndroidRuntime(32366): Caused by: java.lang.NoClassDefFoundError: android.support.v4.view.ViewConfigurationCompat
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.initCustomViewAbove(CustomViewAbove.java:167)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.<init>(CustomViewAbove.java:157)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.<init>(CustomViewAbove.java:152)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:209)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:192)
08-20 15:02:52.060: E/AndroidRuntime(32366): ... 24 more
这是我的代码:
主要的:
package com.cvapp;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivity;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
public class SecondActivity extends SlidingActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
setBehindContentView(R.layout.activity_menu1);
getSlidingMenu().setBehindOffset(100);
SlidingMenu menu = getSlidingMenu();
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
setOnClickListener();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.second, menu);
return true;
}
}
xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@drawable/pic9"
android:clickable="true"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".SecondActivity" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="16dp"
android:layout_marginTop="27dp"
android:text="Hello"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
</RelativeLayout>
而且,如果有帮助,我已按照本教程设置滑动菜单。