Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable the window's title in a FragmentActivity?

In my activity that extends the FragmentActivity class, I can't disable the title using this.requestWindowFeature(Window.FEATURE_NO_TITLE);. It gives an ANR.

How can I disable a FragmentActivity's title?

This is the partial code of the activity's start:

public class NewOrderActivity extends FragmentActivity implements TabListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        ...
    }
}

EDIT: ANSWER:

Okay, I found out that in an activity that has an ActionBar declared in it, the title is a part of the Action Bar not the windows itself.

so in my code I did this to get rid of the window's ( or better to say, ActionBar's ) title:

...
...
final ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(Window.FEATURE_NO_TITLE);
...
...
like image 861
Bardya Momeni Avatar asked Mar 06 '13 22:03

Bardya Momeni


3 Answers

you should use:- getSupportActionBar().setDisplayShowTitleEnabled(false);

getSupportActionBar().setDisplayShowHomeEnabled(false);

like image 184
kirankk Avatar answered Nov 08 '22 14:11

kirankk


Try applying *.NoActionBar theme to activity in your AndroidManifest.xml

<activity 
    android:name=".NewOrderActivity"
    android:theme="@android:style/Theme.Holo.NoActionBar">
    <!-- ... -->
</activity>
like image 39
Andrii Chernenko Avatar answered Nov 08 '22 14:11

Andrii Chernenko


This trick solves your problem :)

ActionBar bar = getActionBar();    
bar.hide();

or

    ActionBar bar = getActionBar();
    bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayShowTitleEnabled(false);
like image 1
Ayaz Alifov Avatar answered Nov 08 '22 12:11

Ayaz Alifov