I added an action bar with a dropdown menu to my activity but it also shows the application name.
Each of my activities has an action bar and each of them use the th
use this in your activity tag of menifeast
android:theme="@android:style/Theme.NoTitleBar"
For this kind of simple stuff you just have to go to the source to find the answer: here the full explanation: http://developer.android.com/guide/topics/ui/actionbar.html#Dropdown
and here some guide code, to include the spinner on the action bar:
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
after that is just put a listener for the changes and setting the a spinner adapter.
and you can use:
setTitle("");
to remove the title. I've been checking on my codes here, you can also give a try on:
requestWindowFeature(Window.FEATURE_NO_TITLE);
It should just remove the title, and leave the title bar. Remember that you must call this before setContentView
happy coding.
The above proposed solutions still show the title for a brief moment before making it invisible. I use the following which I believe is the best way to achieve this:
Simple disable app_name in the activity declaration in the Manifest. This way it will never show for the activity where you don't want it to appear:
<activity
android:name="com.myapp.MainActivity"
android:label="@string/app_name" > <!-- Delete this -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Can be done with a nice one liner
getActionBar().setDisplayShowTitleEnabled(false)
this will hide just the title. If you also want to hide the home logo
getActionBar().setDisplayShowHomeEnabled(false);
When using the AppCompat Support library, you should replace getActionBar()
with getSupportActionBar()
. It is also suggested that you check if the ActionBar is null before changing values on it.
ActionBar actionBar = getSupportActionBar()
if (actionBar != null) {
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
}