1

我正在构建需要实现滑动菜单的应用程序。所以我已经集成了这个库。但是当我启动此活动时,我的应用程序会崩溃。这是 xml、java 和堆栈跟踪的片段。

xml文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />

    <com.slidingmenu.lib.SlidingMenu
        xmlns:sliding="http://schemas.android.com/apk/res-auto"
        android:id="@+id/slidingmenulayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        sliding:viewAbove="@layout/activity_main"
        sliding:viewBehind="@layout/red" >
    </com.slidingmenu.lib.SlidingMenu>


</RelativeLayout>

.java文件:

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        SlidingMenu menu = (SlidingMenu) findViewById(R.id.slidingmenulayout);
        menu.setMode(SlidingMenu.LEFT);
        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
        menu.setFadeDegree(0.35f);
        menu.setShadowWidth(5);
        menu.setBehindWidth(200);
        menu.setSlidingEnabled(true);
        menu.setBehindScrollScale(0.5f);
        menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
        menu.setMenu(R.layout.red);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}

和错误日志:

02-05 14:12:50.024: E/AndroidRuntime(1072): FATAL EXCEPTION: main
02-05 14:12:50.024: E/AndroidRuntime(1072): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.slidingdrawerexample/com.example.slidingdrawerexample.MainActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class com.slidingmenu.lib.SlidingMenu
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.app.ActivityThread.access$600(ActivityThread.java:123)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.os.Handler.dispatchMessage(Handler.java:99)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.os.Looper.loop(Looper.java:137)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.app.ActivityThread.main(ActivityThread.java:4424)
02-05 14:12:50.024: E/AndroidRuntime(1072): at java.lang.reflect.Method.invokeNative(Native Method)
02-05 14:12:50.024: E/AndroidRuntime(1072): at java.lang.reflect.Method.invoke(Method.java:511)
02-05 14:12:50.024: E/AndroidRuntime(1072): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
02-05 14:12:50.024: E/AndroidRuntime(1072): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
02-05 14:12:50.024: E/AndroidRuntime(1072): at dalvik.system.NativeStart.main(Native Method)
02-05 14:12:50.024: E/AndroidRuntime(1072): Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class com.slidingmenu.lib.SlidingMenu
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-05 14:12:50.024: E/AndroidRuntime(1072): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:268)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.app.Activity.setContentView(Activity.java:1835)
02-05 14:12:50.024: E/AndroidRuntime(1072): at com.example.slidingdrawerexample.MainActivity.onCreate(MainActivity.java:16)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.app.Activity.performCreate(Activity.java:4465)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
02-05 14:12:50.024: E/AndroidRuntime(1072): ... 11 more
02-05 14:12:50.024: E/AndroidRuntime(1072): Caused by: java.lang.reflect.InvocationTargetException
02-05 14:12:50.024: E/AndroidRuntime(1072): at java.lang.reflect.Constructor.constructNative(Native Method)
02-05 14:12:50.024: E/AndroidRuntime(1072): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
02-05 14:12:50.024: E/AndroidRuntime(1072): ... 22 more
02-05 14:12:50.024: E/AndroidRuntime(1072): Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-05 14:12:50.024: E/AndroidRuntime(1072): at com.slidingmenu.lib.SlidingMenu.setContent(SlidingMenu.java:342)
02-05 14:12:50.024: E/AndroidRuntime(1072): at com.slidingmenu.lib.SlidingMenu.(SlidingMenu.java:235)
02-05 14:12:50.024: E/AndroidRuntime(1072): at com.slidingmenu.lib.SlidingMenu.(SlidingMenu.java:190)
02-05 14:12:50.024: E/AndroidRuntime(1072): ... 25 more
02-05 14:12:50.024: E/AndroidRuntime(1072): Caused by: java.lang.reflect.InvocationTargetException
02-05 14:12:50.024: E/AndroidRuntime(1072): at java.lang.reflect.Constructor.constructNative(Native Method)
02-05 14:12:50.024: E/AndroidRuntime(1072): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
02-05 14:12:50.024: E/AndroidRuntime(1072): ... 33 more
02-05 14:12:50.024: E/AndroidRuntime(1072): Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-05 14:12:50.024: E/AndroidRuntime(1072): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-05 14:12:50.024: E/AndroidRuntime(1072): at com.slidingmenu.lib.SlidingMenu.setContent(SlidingMenu.java:342)
02-05 14:12:50.024: E/AndroidRuntime(1072): at com.slidingmenu.lib.SlidingMenu.(SlidingMenu.java:235)
02-05 14:12:50.024: E/AndroidRuntime(1072): at com.slidingmenu.lib.SlidingMenu.(SlidingMenu.java:190)
02-05 14:12:50.024: E/AndroidRuntime(1072): ... 36 more
02-05 14:12:50.024: E/AndroidRuntime(1072): Caused by: java.lang.reflect.InvocationTargetException
02-05 14:12:50.024: E/AndroidRuntime(1072):
4

0 回答 0