0

Why is it that every time I make a new activity?

e.g. code:

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

the app bar menu items are gone? :(

Can anyone tell me what to do so every time I open a new activity, the same app bar and menus are always present?

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

AnyHelpPls
  • 11
  • 7

1 Answers1

0

this is different solution but working current in my project .use fragment in Activity and on click call another fragment use two fragment u will get 1 menu bar and if you want activity u have to make action bar every activity

android_jain
  • 788
  • 8
  • 19
  • use toolbar just copy past in all activity – android_jain Feb 08 '17 at 12:40
  • I know about fragments but I need to make a new activity since I need to put a search view and list view inside that activity. My toolbar has icons and I have to follow it that way since that's how our state diagrams should do. – AnyHelpPls Feb 08 '17 at 12:48
  • I read from an answer from a post here that I can't put a search view inside a fragment. :( – AnyHelpPls Feb 08 '17 at 12:49