Reputation: 15734
I have a Fragment Activity which contains two Fragments. In one of the fragments I have a task class called HelpfulTask
I generally access it like this:
new HelpfulTask().execute();
But I need to access it from inside my adapter which is in a separate class outside of this Fragment activity.
Again, here is layout:
MainActivity extends FragmentActivity {
Fragment A {
}
Fragment B extends ListFragment {
class HelpfulTask extends AsyncTask {
// How do I call/access this from separate Arraydapter?
}
}
}
Upvotes: 0
Views: 1168
Reputation: 117597
Two options:
FragmentA
, like:MainActivity a = ... // get reference to the activity instance
MainActivity.FragmentA fa = a.new FragmentA();
MainActivity.FragmentA.HelpfulTaskextends h = fa.new HelpfulTaskextends();
static
, so that you can access them in static way (without instances):MainActivity.FragmentA.HelpfulTaskextends h = new MainActivity.FragmentA.HelpfulTaskextends();
Upvotes: 1