Show title bar from code

Lukap picture Lukap · Apr 29, 2013 · Viewed 11.8k times · Source

In the manifest file I have this line to my application tag

android:theme="@android:style/Theme.NoTitleBar"

and basically every activity doesn't have a title bar, but for one of the activities I want to show the title bar

I know that to hide the bar I can use this code

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

How can I show title bar from code ?

EDIT PLEASE do not tall me how can I hide the title bar :), I know that, if anybody know how can I show it ?

I know that I can put NoTitleBar in every activity that I want to hide and I can leave it for the one I want to be shown... But that was not my point

Answer

Eugine picture Eugine · Jun 5, 2013

For me thous lines of code work perfectly:

Hide:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

Show:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);