2017-02-08 5 views
0

新しいアクティビティを作成するたびになぜですか?新しいアクティビティを作成するたびにAndroid Appのバーメニューが消えます

コード:

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

アプリケーションバーのメニュー項目はなくなりましたか? :(

誰もが私が新しいアクティビティを開くたびに何をすべきかを教えてもらえます、同じアプリバーとメニューは常に存在している

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

NextActivityのXMLを投稿できますか?また、アプリケーションバーが表示されているMainActivityのxml –

+0

@BlancheNeedsHelp NextActivityのビューの内容を確認してテーマをチェックし、質問を投稿するときに関連するものをすべて投稿することを確認してください。 –

+2

オプションメニューを設定する必要がありますすべての活動 –

答えて

0

これは別の解決策ですが、私のプロジェクトでは現在作業中です。アクティビティとクリックコールで別のフラグメントを使用すると、1つのメニューバーが表示され、アクティビティが必要な場合はアクションbすべてのアクティビティ

+0

ツールバーを使用するだけで、すべてのアクティビティが過去コピーされます –

+0

フラグメントについて知っていますが、そのアクティビティ内に検索ビューとリストビューを配置する必要があるため、新しいアクティビティを作成する必要があります。私のツールバーにはアイコンがあり、それは私たちの状態図がどのようにしなければならないかという点でそれに従わなければなりません。 – AnyHelpPls

+0

私はここで記事からの回答を読んで、フラグメント内に検索ビューを置くことはできません。 :( – AnyHelpPls

関連する問題