-2

i need help for this . I realize sth very strange about this. In order to disable the Action bar (Title) , i need to add in this code

requestWindowFeature(Window.FEATURE_NO_TITLE);

So this only works I change from

extends AppCompatActivity

To this

extends Activity

So after changing that, I got error for the getFragmentManager.

Please have a look at the screenshot. And let me know if u guys have any idea wads going on? THx

enter image description here

gosulove
  • 1,645
  • 2
  • 26
  • 40

4 Answers4

8

Use getSupportFragmentManager() instead of getFragmentManager(). AppCompatActivity is v4 library therefore required to use v4 functions

And to use it in Activity instead of Activity change it to FragmentActivity. Then you can use getSupportFragmentManager()

Jimit Patel
  • 4,265
  • 2
  • 34
  • 58
3

requestWindowFeature() is not supported in AppCompatActivity thats why you could not use that method with AppCompatActivity.

Also if you are using AppCompatActivity you need to use SupportFragment and if you use Activity then use Fragment.

Shubham Naik
  • 410
  • 1
  • 7
  • 18
  • requestWindowFeature() is not supported in AppCompatActivity , Any solution for this ? so how to disable the Action bar ? – gosulove Jul 19 '16 at 08:34
  • see if this helps you: http://stackoverflow.com/questions/18526144/actionbarcompat-hide-actionbar-before-activity-is-created-bug – Shubham Naik Jul 19 '16 at 08:36
1

If you are using this import import android.support.v4.app.Fragment;,

then you must use getSupportFragmentManager.

Hope this helps.

Chris Palma
  • 223
  • 1
  • 2
  • 13
1

You have to use the Compat method getSupportFragmentManager() instead of the regular one.

That's because it returns an object of type android.app.FragmentManager which is the type of the object where you're trying to store it.

If you use the regular method getFragmentManager() it'll return an object of type android.app.FragmentManager, which is an incompatible type.

Alber8295
  • 763
  • 1
  • 8
  • 19
  • Sorry for that. I mean *Support. Edited now. I was thinking in Compatibility and Support and I've mislead. – Alber8295 Jul 19 '16 at 08:42