1

In my android project, I wish to disable icon and the title in ActionBar.

Here is the code:

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getActionBar().setDisplayShowTitleEnabled(false);
        getActionBar().setDisplayShowHomeEnabled(false);
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

But always on startup they appear and after a while they disappear but i don't want them at all. How can i remove them on startup?

Rethinavel
  • 3,912
  • 7
  • 28
  • 49
c_user89
  • 53
  • 1
  • 9

4 Answers4

0

call setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false) on your ActionBar.

actionBar.setDisplayUseLogoEnabled(false); should do it.

Or

For Splashscreen you should use this line in manifest and don't use getActionBar()

<item name="android:windowActionBar">false</item>

and once when Splash Activity is finished in the main Activity use below or nothing

<item name="android:windowActionBar">true</item>

Reffer this ----> click here

Community
  • 1
  • 1
ashish.n
  • 1,234
  • 14
  • 30
  • i added false 0dp and it disappear. but if i want to reappear it during the main activity what should i do? those: getWindow().requestFeature(Window.FEATURE_ACTION_BAR); getActionBar().show(); dont help – c_user89 Apr 10 '14 at 08:44
0

You can use below code for that -

<activity android:name="YourActivityname" android:theme="@android:style/Theme.NoTitleBar" />

If you want the full screen of your device you can use below code -

<activity android:name="YourActivityname" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />

And, also refer Developer's Site

Another method

Do this in your onCreate() method.

    //Remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    //Remove notification bar
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

   //set content view AFTER ABOVE sequence (to avoid crash)
    this.setContentView(R.layout.your_layout_name_here); 

this refers to the Activity.

Lal
  • 14,726
  • 4
  • 45
  • 70
  • i tried the second method you told me and the same thing.i added false 0dp and i got what i wanted but i have now trouble reappearing the actionbar.this: getActionBar().show(); doesnt help – c_user89 Apr 10 '14 at 09:09
  • Make sure the `setContentView(view)` has been already called for your Activity, otherwise `getActionBar()` will return null. – Lal Apr 10 '14 at 10:23
  • also check that `` is there in the manifest – Lal Apr 10 '14 at 10:25
0

Maybe this answer can help you. It helped me.

<quote>
Best method is to set the display options to useLogo in your theme. E.g.

<style name="AppTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
</style>

<style name="AppTheme.ActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid">
    <item name="android:displayOptions">useLogo</item>
</style>

This won't actually show the logo (if set) because showHome is not included.
</quote>

Community
  • 1
  • 1
sandalone
  • 41,141
  • 63
  • 222
  • 338
-1

try this:

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);

    setContentView(R.layout.activity_main);
}

NOTE: The getActionBar() method was added in Honeycomb (API: 11) and later

The Badak
  • 2,010
  • 2
  • 16
  • 28