Bundle Pass Parameters
Fragment1 fragment1 = new Fragment1 ();
Bundle bundle = new bundle ();
Bundle.putstring ("name", "Zhang San");
Fragment1.setarguments (bundle);
Fragmentmanager fm = Getfragmentmanager ();
Fragmenttransaction transaction = Fm.begintransaction ();
Transaction.addtobackstack (NULL);
Transaction.add (R.ID.CONTENT,FRAGMENT1);
Transaction.hide (Homefragment.this);
Transaction.commit ();
It is important to note that the existing fragment is going to use the bundle to pass the parameters.
The acceptance parameters are relatively simple, and half of the time will be considered in the fragment Onattach life cycle to accept.
The code is as follows:
Bundle arguments = getarguments ();
String name = arguments.getstring ("name");
Of course, we'd better have to judge if the value obtained is not NULL, because it is possible to not get the data from the server when there is no network, it will not be accepted here.
Data transfer for Android fragment