导入RikkaMusic项目/main/adapter/MultiFragmentPagerAdapter文件,运行出现BUG,求解,实在找不到修改的方法
public class MultiFragmentPagerAdapter extends FragmentStatePagerAdapter {
private static final String TAG = "MultiFragmentPagerAdapt";
**创建的fragments类型是BaseFragment的List
private List<BaseFragment> fragments = new ArrayList<>();
public MultiFragmentPagerAdapter(FragmentManager fm) {
super(fm);
}
public void init(List<BaseFragment> fragmentList) {
fragments.clear();
fragments.addAll(fragmentList);
}
@Override
**然后这里用的是Fragment类型
public Fragment getItem(int i) {
if (fragments != null && i < fragments.size()) {
return fragments.get(i); // 报错,提供的类型是BaseFragment,要求的是Fragment。但BaseFragment继承的是Fragment
}
return null;
}