【问题标题】:FragmentManager can't resolve in androidxFragmentManager 无法在 androidx 中解析
【发布时间】:2019-10-05 10:05:42
【问题描述】:

FragmentManagerbeginTransaction 无法在 androidx 中解析

   FragmentManager fM = getSupportFragmentManager();

   FragmentTransaction fragmentTransaction = fM.beginTransaction();

【问题讨论】:

    标签: java android android-studio android-appcompat androidx


    【解决方案1】:

    androidx.appcompat.app.AppCompatActivityandroidx.fragment.app.Fragment 中只需使用导入:

    import androidx.fragment.app.FragmentManager;
    

    该类位于androidx.fragment:fragment:x.x.x 库中,该库是androidx.appcompat:appcompat 的依赖项。 只需使用:

    implementation 'androidx.appcompat:appcompat:1.1.0'
    

    【讨论】:

    • 谢谢,添加此依赖后,它现在可以正常工作了。
    • 嗨@KhadijaHameed,如果这个或任何答案解决了您的问题,请点击复选标记考虑accepting it。这向更广泛的社区表明您已经找到了解决方案,并为回答者和您自己提供了一些声誉。没有义务这样做。
    猜你喜欢
    • 2019-02-14
    • 2021-06-22
    • 1970-01-01
    • 2019-11-09
    • 2019-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多