2017-02-08 2 views
0

Warum ist es so, dass jedes Mal, wenn ich eine neue Aktivität mache?Android App Bar-Menü verschwindet jedes Mal, wenn ich eine neue Aktivität erstellen

z.B. code:

Intent intent = new Intent(getApplicationContext(), NextActivity.class; 
startActivity(intent); 

die app bar menü artikel sind weg? :(

Kann mir jemand sagen, was jedes Mal, wenn ich eine neue Tätigkeit zu tun, so zu öffnen, die gleiche App-Leiste und Menüs sind immer vorhanden

EDITED:

**activity.xml** 



       <?xml version="1.0" encoding="utf-8"?> 
      <android.support.v4.widget.DrawerLayout 
       xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:app="http://schemas.android.com/apk/res-auto" 
       xmlns:tools="http://schemas.android.com/tools" 
       android:id="@+id/drawer_layout" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:fitsSystemWindows="true" 
       tools:openDrawer="start"> 

       <include 
        layout="@layout/app_bar_main" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" /> 

       <android.support.design.widget.NavigationView 
        android:id="@+id/nav_view" 
        android:layout_width="wrap_content" 
        android:layout_height="400dp" 
        android:layout_gravity="start" 
        android:fitsSystemWindows="true" 
        app:headerLayout="@layout/nav_header_main" 
        app:menu="@menu/activity_main_drawer" /> 

     </android.support.v4.widget.DrawerLayout> 


**activity_intention.xml:** 
    <?xml version="1.0" encoding="utf-8"?> 
    <android.support.design.widget.CoordinatorLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     tools:openDrawer="start"> 




*I'll also include the app_bar_main.xml* 




     <?xml version="1.0" encoding="utf-8"?> 
     <android.support.design.widget.CoordinatorLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      tools:context="com.example.beminix.dcar.MainActivity"> 

      <android.support.design.widget.AppBarLayout 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:theme="@style/AppTheme.AppBarOverlay"> 

       <android.support.v7.widget.Toolbar 
        android:id="@+id/toolbar" 
        android:layout_width="match_parent" 
        android:layout_height="?attr/actionBarSize" 
        android:background="?attr/colorPrimary" 
        app:popupTheme="@style/AppTheme.PopupOverlay" /> 

      </android.support.design.widget.AppBarLayout> 

      <include layout="@layout/content_main"/> 



     </android.support.design.widget.CoordinatorLayout> 

The toolbar that I want to keep using The 3 menu icons are gone so as the title

+0

können Sie die XML für die NextActivity? sowie das xml für die MainActivity, wo die App Bar angezeigt wird –

+0

@BlancheNeedsHelp überprüfen Sie den Inhalt der Ansicht Ihrer NextActivity überprüfen Sie das Thema und wenn Sie eine Frage stellen Sie sicher, dass Sie alle verwandten Sachen –

+2

Sie müssen Optionsmenü in setzen jede Aktivität –

Antwort

0

Dies ist eine andere Lösung aber Arbeitsstrom in meinem Projekt .use Fragment in Aktivität und auf klicken Sie auf ein anderes Fragment verwenden Sie zwei Fragment Sie erhalten 1 Menüleiste und wenn Sie wollen, Aktivität müssen Sie Maßnahmen b Jede Aktivität

+0

verwenden Sie die Symbolleiste kopieren Sie einfach Vergangenheit in allen Aktivitäten –

+0

Ich weiß über Fragmente, aber ich muss eine neue Aktivität machen, da ich eine Suchansicht und Listenansicht innerhalb dieser Aktivität setzen muss. Meine Symbolleiste hat Icons und ich muss sie so verfolgen, da dies unsere Zustandsdiagramme tun sollten. – AnyHelpPls

+0

Ich habe hier aus einer Antwort von einem Beitrag gelesen, dass ich keine Suchansicht in ein Fragment einfügen kann. :( – AnyHelpPls

Verwandte Themen