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

Maxj picture Maxj · May 2, 2013 · Viewed 12k times · Source

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)

Answer

Prototik picture Prototik · May 3, 2013

See flag ThemeManager.NO_ACTION_BAR. Or just call

getSupportActionBar().hide();