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);
...
...
Bardya Momeni
  • 337
  • 4
  • 13

3 Answers3

2

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

getSupportActionBar().setDisplayShowHomeEnabled(false);

kirankk
  • 628
  • 1
  • 9
  • 22
1

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

<activity 
    android:name=".NewOrderActivity"
    android:theme="@android:style/Theme.Holo.NoActionBar">
    <!-- ... -->
</activity>
Andrii Chernenko
  • 9,873
  • 7
  • 71
  • 89
  • 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. – Bardya Momeni Mar 06 '13 at 23:00
1

This trick solves your problem :)

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

or

    ActionBar bar = getActionBar();
    bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayShowTitleEnabled(false);
Ayaz Alifov
  • 8,334
  • 4
  • 61
  • 56