I am trying to call getActivity() in the OnItemClickListener:
class ViewTest{ //called in a fragment
setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int p, long i) {
((MainActivity) getActivity()).makeResultsbarVisible();
...
}
});
}
In the fragment, the class is instantiated as:
ViewTest editTest = new ViewTest(this);
But I get an error that I cannot fix:
The method getActivity() is undefined for the type new AdapterView.OnItemClickListener(){}
How can I call getActivity inside onItemClick()? Thanks.