FragmentManager 无法在 androidx 中解析

FragmentManager can't resolve in androidx

FragmentManagerbeginTransaction 无法在 androidx

中解析
   FragmentManager fM = getSupportFragmentManager();

   FragmentTransaction fragmentTransaction = fM.beginTransaction();

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

import androidx.fragment.app.FragmentManager;

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

implementation 'androidx.appcompat:appcompat:1.1.0'