obj Fragment wrong 2nd argument type found 'Android.support.V4.app.Fragment.' required 'Android.app.Fragment'

前端 未结 4 1266
醉梦人生
醉梦人生 2020-12-30 21:50

I can\'t work out why my objFragment is giving me issues with the support manager, I\'m getting this error:

 Error:(101, 17) error: no suitable method found         


        
4条回答
  •  猫巷女王i
    2020-12-30 21:56

    The problem is that there is a mismatch in fragments types between objFragment and fragmentManager. The first is from package android.support.v4.app while the second is from the android.app package.

    See this answer here to know the difference between the two types of Fragments.

    Now to fix the issue you have to handle your imports.

    Either use import android.app.Fragment instead of import android.support.v4.app.Fragment

    Or do as Modge suggested; Update the main content of your app with a support Fragment manager like this: FragmentManager fragmentManager = getSupportFragmentManager(). But then you also have to change the type of the FragmentManager itself; import android.app.FragmentManager to import android.support.v4.app.FragmentManager;

提交回复
热议问题