我想扩展Fragment
课程,但我希望能够将我的课程与 HoloEverywhere 和默认片段一起使用......
所以我尝试使用装饰器......
public abstract class RFragment<F extends Fragment, I extends LayoutInflater> extends Fragment implements IKey
{
private final Class<F> mFragmentClass;
private final Class<I> mInflatorClass;
public RFragment(Class<F> fragmentClass, Class<I> inflatorClass)
{
this.mFragmentClass = fragmentClass;
this.mInflatorClass = inflatorClass;
}
}
我现在也想覆盖onCreateView
,但我做不到。我尝试如下:
@Override
public View onCreateView(I inflater, ViewGroup container, Bundle savedInstanceState)
{
if (view == null)
{
view = doOnCreateView(inflater, container, savedInstanceState);
loadingIndicator = doGetLoadingIndicatorView(view);
}
return view;
}
protected abstract View doOnCreateView(I inflater, ViewGroup container, Bundle savedInstanceState);
protected abstract View doGetLoadingIndicatorView(View view);
但这是不允许的,因为如果参数不匹配,我无法覆盖该函数(I!= LayoutInflator)
有没有可能解决这个问题?我想避免复制我的类,只需将默认片段和默认 LayoutInflator 中的导入更改为 HoloEveryhwere 中的导入(仅扩展默认类)...