java - null pointer exception from toolbar when set to landscape -


the app , toolbar work fine in portrait mode set landscape mode app crashes.

here logcat

caused by: java.lang.nullpointerexception @ android.support.v7.internal.widget.toolbarwidgetwrapper.<init>(toolbarwidgetwrapper.java:94) @ android.support.v7.internal.widget.toolbarwidgetwrapper.<init>(toolbarwidgetwrapper.java:87) @ android.support.v7.internal.app.toolbaractionbar.<init>(toolbaractionbar.java:77) @ android.support.v7.app.appcompatdelegateimplv7.setsupportactionbar(appcompatdelegateimplv7.java:198) @ android.support.v7.app.appcompatactivity.setsupportactionbar(appcompatactivity.java:96) @ maxbleggi.afstudentplanner.activities.mainactivity.oncreate(mainactivity.java:104) @ android.app.activity.performcreate(activity.java:5323) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1088) @ android.app.activitythread.performlaunchactivity(activitythread.java:2302) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2390) @ android.app.activitythread.handlerelaunchactivity(activitythread.java:3930) @ android.app.activitythread.access$900(activitythread.java:151) @ android.app.activitythread$h.handlemessage(activitythread.java:1327) @ android.os.handler.dispatchmessage(handler.java:110) @ android.os.looper.loop(looper.java:193) @ android.app.activitythread.main(activitythread.java:5292) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:515) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:824) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:640) @ dalvik.system.nativestart.main(native method) 

here toolbar (tool_bar.xml)

<android.support.v7.widget.toolbar android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="@color/primary" android:elevation="4dp" android:theme="@style/themeoverlay.appcompat.dark" android:popuptheme="@style/themeoverlay.appcompat.light" android:fitssystemwindows="true" xmlns:android="http://schemas.android.com/apk/res/android"> </android.support.v7.widget.toolbar> 

here activity main

<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/drawer" android:fitssystemwindows="true">  <linearlayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical">      <include         android:id="@+id/tool_bar"         layout="@layout/tool_bar">     </include>      <framelayout         android:id="@+id/fragment_container"         android:layout_width="match_parent"         android:layout_height="match_parent">      </framelayout>  </linearlayout>  <android.support.design.widget.navigationview     android:id="@+id/navigation_view"     android:layout_width="wrap_content"     android:layout_height="match_parent"     android:layout_gravity="start"     app:headerlayout="@layout/drawer_header"     app:menu="@menu/drawer"/> 

here line of code throws exception

// initialise , set toolbar actionbar toolbar = (toolbar) findviewbyid(r.id.tool_bar); setsupportactionbar(toolbar); 

and

maxbleggi.afstudentplanner.activities.mainactivity.oncreate(mainactivity.java:104) 

is line specifically

 setsupportactionbar(toolbar); 


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -