Android Fragment no view found for ID?

前端 未结 30 2427
逝去的感伤
逝去的感伤 2020-11-22 05:33

I have a fragment I am trying to add into a view.

FragmentManager fragMgr=getSupportFragmentManager();
feed_parser_activity content = (feed_parser_activity)f         


        
30条回答
  •  借酒劲吻你
    2020-11-22 05:55

    Sometimes it is because you are using a BottomNavigationView. If you open an Intent from the navigation and in that activity you open a fragment lets say

    transaction.replace(R.id.container,new YourFragment());
    

    then the Activity won't be able to find the navigation method you are using.

    SOLUTION: Change the activity to fragment and handle navigation with addOnBackStack in your app. If you've implemented the Jetpack Navigation just use fragments in your project.

提交回复
热议问题