I have a question regarding the use of context in a fragment. My problem is that I always get a NullpointerException. That's what I'm doing:
Create a class that extends the Sherlock fragment. In this class, I have an instance of another Helper class:
public class Fragment extends SherlockFragment { private Helper helper = new Helper(this.getActivity());
Here is an excerpt from another Helper class:
public class Helper { public Helper(Context context) { this.context = context; }
Every time I call context.someMethod (e.g. context.getResources ()), I get a NullPointerException. Why is this?
java android nullpointerexception android-context
user2426316
source share