The method add(Fragment) in the type ArrayList<Fragment> is not applicable for the arguments (ImageF

来源:互联网 发布:洛天依黑暗五部曲 知乎 编辑:程序博客网 时间:2024/05/22 15:13

Fragment调用add方法的时候一直报错的原因:

  • add(Fragment)方法中的参数类型和List 中的参数类型不匹配
  • 换句话说如下图所示的 List中的参数也就是Fragment是android.app.Fragment类型,但是NewsFragment StoryFragment 都是extends android.support.v4包下的Fragment
  • 也就是参数类型不匹配,需要将参数类型改成一样的即可,我这里将List 中的Fragment 改成android.support.v4包下的Fragment

0 0
原创粉丝点击