The method replace(int, Fragment, String) in the type FragmentTransaction is not applicable for the

本文解决了一个关于Android开发中Fragment替换时出现的不适用参数错误。问题源于错误地使用了android.app.Fragment而非android.support.v4.app.Fragment。文中详细解释了两者的区别及API版本的要求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



The method replace(int, Fragment, String) in the type FragmentTransaction is not applicable for the arguments (int, SettingFragment, String)


今天遇到这样一个很奇葩的错误信息,后来查到我导入的包有问题  import android.app.Fragment;
import android.app.FragmentManager;   其实我应该使用的是  import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;   然后自己查看了一下API二者差别还是蛮大的   import android.app.Fragment 只能在API版本大于11的时候使用   而不包含getFragmentManager() 和 getSupportFragmentManager()  两个方法的   虽然在代码这样写不会报错的  但是  replace(int, Fragment, String)执行的时候会一直出现错误   提示上面那个错误信息


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值