Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Holoeverywhere : how to programmatically remove at runtime the action bar from an activity

Which is the correct way to remove the action bar inside an activity ?

My activity extends org.holoeverywhere.app.Activity

I've a custom Application class that extends org.holoeverywhere.app.Application and at startup execs this static code :

ThemeManager.setDefaultTheme(ThemeManager.DARK);
ThemeManager.map(ThemeManager.DARK, R.style.Holo_Demo_Theme);
ThemeManager.map(ThemeManager.LIGHT,  R.style.Holo_Demo_Theme_Light);
ThemeManager.map(ThemeManager.MIXED, R.style.Holo_Demo_Theme_Light_DarkActionBar);
ThemeManager.map(ThemeManager.DARK | ThemeManager.FULLSCREEN,  R.style.Holo_Demo_Theme_Fullscreen);
ThemeManager.map(ThemeManager.LIGHT | ThemeManager.FULLSCREEN, R.style.Holo_Demo_Theme_Light_Fullscreen);
ThemeManager.map(ThemeManager.MIXED | ThemeManager.FULLSCREEN, R.style.Holo_Demo_Theme_Light_DarkActionBar_Fullscreen);

in my activity :

protected void onCreate(Bundle savedInstanceState) {

    ThemeManager.removeTheme(this);
    setTheme(ThemeManager.DARK | ThemeManager.FULLSCREEN);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

if I add requestWindowFeature(Window.FEATURE_NO_TITLE) in the code, on an android 4.1.1 -table- the bar is removed while on an handset -android 2.3.3- the bar is not removed.

Before introducing holoeverywhere everything worked fine with just requestWindowFeature(Window.FEATURE_NO_TITLE).

Which is the correct way to remove at runtime the actionbar in holoeverywhere ? (I want to do it at runtime because the user has the option to set a DARK or LIGHT layout, with a DARK default)

like image 345
Maxj Avatar asked May 02 '13 17:05

Maxj


2 Answers

See flag ThemeManager.NO_ACTION_BAR. Or just call

getSupportActionBar().hide();
like image 105
Prototik Avatar answered Nov 03 '22 01:11

Prototik


You can do it programatically:

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class ActivityName extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // remove title
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);
    }
}

Or you can do it via your AndroidManifest.xml file:

<activity android:name=".ActivityName"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
</activity>

I added some lines so that you can show it in fullscreen, as it seems that's what you want.

like image 35
Chintan Soni Avatar answered Nov 03 '22 01:11

Chintan Soni