0

I'm new to Android development, so sorry if this is a stupid question. I have disabled Action Bar in AndroidManifest.xml like this android:theme="@style/AppTheme.NoActionBar" but I'm in need of Action Bar in a certain activity. How do I create and set new Action Bar only to that activity?

Edit: I forgot to mention that the activity I want to have an Action Bar is child of the activity with no Action Bar. I guess this causes the problems.

1

5 Answers 5

1

Define the theme for that perticular activity in the menifest.

<activity
android:theme="@style/AppTheme.NoActionBar"
>
1

The best way is for this problem

<activity android:name=".MainActivity"  android:theme="@style/AlertDialog.AppCompat.Light" android:label="activity_with_actionbar" />

And

    <activity android:name=".SecondActivity"  android:theme="@style/Theme.AppCompat.NoActionBar" android:label="activity_with_no_actionbar" />
0

You can do the opposite, i.e., In AndroidManifest keep theme as android:theme="@style/AppTheme"

and in Activities that you dont want to see ActionBar, add below code in its onCreate method:

getSupportActionBar().hide();
0

Add theme specifically for each activity inside manifest

<activity
    android:name=".MainActivity"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
  </activity>
0

You can create a custom Action bar. And implement ActionBar class in the activity u needed to have an action bar. Its very easy way to do what you want. Follow this tutorial.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.