How to show the title in Fragment but hide in the Activity?

835 Views Asked by At

I have a Activity and it has include more than one fragment.

I know it can use requestWindowFeature(Window.FEATURE_NO_TITLE); to hide the title in Activity.

But I don't want to hide title for all fragment.

Can I hide the title for preference fragment ?

2

There are 2 best solutions below

2
On

Based on what you say, you will have to use more than one activity. For the fragments that are in a same activity, the title bar is either shown or hidden.

2
On
  1. Do not use requestWindowFeature(Window.FEATURE_NO_TITLE); We can get actionBar and hide it after setContentView

  2. When active fragment, show action bar

  3. When fragment detach , notify activity and activity can hide the action bar

Above is my current implement and seems work. Still testing :-D

Simple sample here - https://bitbucket.org/jimmy64/fragmentsample