使用Fragment时,遇到的问题

来源:互联网 发布:单桂敏淘宝店铺7205286 编辑:程序博客网 时间:2024/05/29 07:46

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

private List<Fragment> homeFragments;homeFragments = new ArrayList<>();homeFragments.add(new MineFragment());


在用add时,会出现The method add(Fragment) in the type List<Fragment> is not applicable for the arguments (MineFragment):

是因为用了系统的import android.app.Fragment; 改成import android.support.v4.view.ViewPager; 就可以解决了。


另外,如果改成import android.support.v4.view.ViewPager; 后,还有些地方出错,就要查看一下是不是引用了一些在外面定义的继承了Fragment的类,这些类同样要改成import android.support.v4.view.ViewPager;  否则一样会出错。

阅读全文
0 0