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?
One more solution-
If you have a parent, you can directly access the context like so-
public class SampleAdapter extends BaseAdapter {
LayoutInflater inflater;
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(inflater == null){
Context context = parent.getContext();
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
...
...
return convertView;
}
}