Android 片段中的上下文类型

Android 片段中的上下文类型,android,fragment,android-context,fragmentpageradapter,Android,Fragment,Android Context,Fragmentpageradapter,我已经实现了一个带有4个选项卡的FragmentPagerAdapter,并且我已经将一个片段关联到每个选项卡。其中一个视图加载带有如下图像的GridView: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState

我已经实现了一个带有4个选项卡的
FragmentPagerAdapter
,并且我已经将一个片段关联到每个选项卡。其中一个视图加载带有如下图像的
GridView

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{

super.onCreateView(inflater, container, savedInstanceState);

View view = inflater.inflate(R.layout.init, container, false);

final GridView grid = (GridView)view.findViewById(R.id.myGrid);            
grid.setNumColumns(2);
grid.setAdapter(new ImageAdapter(getActivity()));

return view;
}
问题是方法
newimageadapter(context)
接收一个变量类型的上下文作为参数加载到方法
newImageView(context)
中,它需要这种类型的变量并传递
getActivity()
我有下一个错误:

无法访问IniSel类型的封闭实例。必须使用IniSel类型的封闭实例限定分配(例如x.new A(),其中x是IniSel的实例)

(IniSel是类名)

我怎么能修理


如何在继承自Fragment的类中传递变量上下文类型?

类ImageAdapter
更改为
静态类ImageAdapter
如果使用内部类,可以参考此页面: