我正在尝试新的导航视图并用它替换我的列表视图,但出现错误:
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: FATAL EXCEPTION: main
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: Process: com.aufmschoolbliz.app, PID: 17368
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aufmschoolbliz.app/com.aufmschoolbliz.app.activities.Main2Activity}: android.view.InflateException: Binary XML file line #14: Error inflating class android.support.design.widget.NavigationView
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:151)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5254)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class android.support.design.widget.NavigationView
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:633)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.transition.Scene.enter(Scene.java:175)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.transitionTo(PhoneWindow.java:433)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:376)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.Activity.setContentView(Activity.java:2145)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.aufmschoolbliz.app.activities.Main2Activity.onCreate(Main2Activity.java:13)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5990)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:151)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5254)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Native Method)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:607)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.transition.Scene.enter(Scene.java:175)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.transitionTo(PhoneWindow.java:433)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:376)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.Activity.setContentView(Activity.java:2145)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.aufmschoolbliz.app.activities.Main2Activity.onCreate(Main2Activity.java:13)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5990)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:151)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5254)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.content.res.Resources.getValue(Resources.java:1266)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.content.res.Resources.getColorStateList(Resources.java:964)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.support.design.widget.NavigationView.createDefaultColorStateList(NavigationView.java:338)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.support.design.widget.NavigationView.<init>(NavigationView.java:124)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.support.design.widget.NavigationView.<init>(NavigationView.java:88)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Native Method)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:607)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.transition.Scene.enter(Scene.java:175)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.transitionTo(PhoneWindow.java:433)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:376)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.Activity.setContentView(Activity.java:2145)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.aufmschoolbliz.app.activities.Main2Activity.onCreate(Main2Activity.java:13)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5990)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:151)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5254)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-15 10:49:13.988 17368-17368/com.aufmschoolbliz.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
我创建了一个没有任何自定义代码的新活动,以验证它是否真的不起作用。但是,我得到同样的错误。
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:id="@+id/navigationView"/>
<!--app:headerLayout="@layout/drawer_student_data_header"-->
</RelativeLayout>