Error incompatible types: android.app.FragmentManager cannot be converted to android.support.v4.app.FragmentManager

后端 未结 1 861
醉酒成梦
醉酒成梦 2021-01-18 15:34

Error Error incompatible types: android.app.FragmentManager cannot be converted to android.support.v4.app.FragmentManager is drving me nuts.

In my app,

1条回答
  •  深忆病人
    2021-01-18 16:22

    Change

    import android.app.Fragment;
    import android.app.FragmentManager;
    

    to

    import android.support.v4.app.Fragment;
    import android.support.v4.app.FragmentManager;
    

    in every class. you are facing problems because in your Fragment creation class you are using support v4 fragment and in your MainActivity class you are inflating as a simple fragment.

    You also need to change getFragmentManager() to getSupportFragmentManager(), and make sure they're extending a FragmentActivity class.

    Hope it will help you.

    0 讨论(0)
提交回复
热议问题