incompatible types: HomeFragment cannot be converted to Fragment in Android

后端 未结 9 1671
轻奢々
轻奢々 2020-12-01 15:57

I\'m getting an error in this part of code:

private void displayView(int position) {
    // update the main content by replacing fragments
    Fragment fragm         


        
9条回答
  •  粉色の甜心
    2020-12-01 16:18

    This seems to be an import problem.

    When using getFragmentMangager(), make sure that your Fragment classes extend android.app.Fragment class.

    If by any chance you are using android.support.v4.app.Fragment (see your imports), then you need to use getSupportFragmentManager() instead

    Hope it helps

提交回复
热议问题