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

前端 未结 4 1257
醉梦人生
醉梦人生 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 22:21

    You tried to use the non support FragmentManager for your transaction. Change it to get the support one.

        // update the main content by replacing fragments
        FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction()
                .replace(R.id.container, objFragment)
                .commit();
    

提交回复
热议问题