我有一类名为 BinderData 延伸
BaseAdapter
。我想要得到的基类上下文。我试图用的getContext()
但是,这并不如遇工作 BaseAdapter
。
I have a class named BinderData
which extends BaseAdapter
. I want to get the base class context. I tried to use getContext()
but that doesn't work in case of BaseAdapter
.
我怎样才能得到这个类的语境?
How can I get the Context of this class?
请一个构造函数一个上下文
作为它的一个参数,并将其存储在私有变量。
Make a constructor that takes a Context
as one of its arguments and store it in a private variable.
public class SampleAdapter extends BaseAdapter {
private Context context;
public SampleAdapter(Context context) {
this.context = context;
}
/* ... other methods ... */
}
上一篇:在片段类成员成为仅次于Home键preSS零等待片段、成员、preSS、Home
下一篇:谷歌地图API的Android V2 - " ACCESS_FINE_LOCATION"我的定位层所需权限启用我的、所需、权限、地图