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

3

6

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);
...
...
Easement answered 6/3, 2013 at 22:48 Comment(2)
Have you tried using a NoTitleBar theme in your manifest?Albino
@Sam: tried it now, it wont work... hmmm any other suggestion?? BTW thanks for quick reply.Easement
A
2

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

getSupportActionBar().setDisplayShowHomeEnabled(false);

Antimagnetic answered 31/7, 2013 at 13:17 Comment(0)
F
1

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

<activity 
    android:name=".NewOrderActivity"
    android:theme="@android:style/Theme.Holo.NoActionBar">
    <!-- ... -->
</activity>
Fetish answered 6/3, 2013 at 22:55 Comment(1)
another ANR. to be exact, I am using an action bar in this activity in tab navigation mode. so setting it to no action bar, gives ANR, logically.Easement
D
1

This trick solves your problem :)

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

or

    ActionBar bar = getActionBar();
    bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayShowTitleEnabled(false);
Dumm answered 22/8, 2014 at 2:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.