1

I am practicing a tutorial. App was working fine before I implemented list view. Now the action bar and the menu options disappeared. Can someone help me to identify the issue.Below is the required code (please advise if more info is required).

activity_home.xml

  <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".HomeActivity"
    tools:showIn="@layout/activity_home">


    <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" />



    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </ListView>
</RelativeLayout>

styles.xml

 <resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

manifest.xml

 <application
        android:name=".Application"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        >

        <activity
            android:name=".HomeActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".LoginActivity"
            android:label="@string/title_activity_register"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".RegisterActivity"
            android:label="@string/title_activity_login"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".UpdateStatusActivity"
            android:label="@string/title_activity_update_status"
            android:theme="@style/AppTheme.NoActionBar"></activity>
    </application>

</manifest>
Spider
  • 367
  • 3
  • 15

3 Answers3

4

Change

 android:theme="@style/AppTheme.NoActionBar" 

in your AndroidManifest.xml file to

  android:theme="@style/AppTheme"

It should work.

piotrek1543
  • 19,130
  • 7
  • 81
  • 94
tiny sunlight
  • 6,231
  • 3
  • 21
  • 42
1

In the manifest you have mentioned AppTheme as the theme of the application but for every activity you have mentioned theme as AppTheme.NoActionBar For HomeActivity you need to use the AppTheme instead of NoActionBar theme Just remove

android:theme="@style/AppTheme.NoActionBar"

From your activity tag in the manifest for HomeActiviy

Ameya Kulkarni
  • 198
  • 1
  • 2
  • 14
0

you used in manifest.xml file android:theme="@style/AppTheme.NoActionBar" don't write android:theme line if you can't change the theme

Nirav Shah
  • 67
  • 10