1 How to run the Fragment method in Acitivty:
First get the object of this fragment
Xxxfragment Fragmentobject = (xxxfragment) getfragmentmanager.findfragmentbytag ("xx");
2 How to run the activity in fragment:
First: Let acitivity inherit the interface
Another: Use Getactivity () in fragment, but add Acitivity's name, namely:
((mainactivity) getactivity ()). XXX ();
3 assume that in fragment to operate a fragment, the first thing to get this object, how to get? Using the Getfragmentbytag of Fragmentmnager in Getactivity, you can then use this fragment object to manipulate his method.
Of course, when you get this fragment, turn it into an object of this fragment. Eg:
Fragmentmanager fm = Getactivity.getsupportfragmentmanager ();
Xxxfragment = (xxxfragment) fm.findfragmentbytag ("xxx")
4 How to operate a fragment in a random class, first of all to get the environmental parameters, how to get?
In the activity :
private static weakreference<actionbuttonactivity> actionbuttonactivty = null;
actionbuttonactivty = new Weakreference<actionbuttonactivity> (this);
This Actionbuttonactivity object is passed from activity to this random class.
Asynctask.setactivity (actionbuttonactivty);
InCasual ClassIn
private static weakreference<actionbuttonactivity> actionbuttonactivty;
public void setactivity (weakreference<actionbuttonactivity> actionbuttonactivty) {this.actionbuttonactivty = Actionbuttonactivty;}
/** * This method was invoked on the UI thread after the background computation * finishes. The result of the background computation is passed to this step * as a parameter. */@Overrideprotected void OnPostExecute (Bitmap result) {Super.onpostexecute (result); Fragmentmanager fm = Actionbuttonactivty.get (). Getfragmentmanager (); Fragmenttransaction ft = fm.begintransaction (); Bfragmenttab_one_event_details Bt_det = (bfragmenttab_one_event_details) fm.findfragmentbytag ("2_det"); Bt_ Det.setevidenceimage (result); bt_det.setbuttonclickable (); Ft.addtobackstack (null). commit ();}
OK The call relationship between all classes and fragment has been described above.
How to operate in a fragment or discretionary class there is a method in the fragment