原文:http://stackoverflow.com/questions/7149802/how-to-transfer-some-data-to-another-fragment
Use a Bundle. Here's an example:
Fragment fragment = new Fragment();
Bundle bundle = new Bundle();
bundle.putInt(key, value);
fragment.setArguments(bundle);
Bundle has put methods for lots of data types. Seehttp://developer.android.com/reference/android/os/Bundle.html
Then in your Fragment, retrieve the data (e.g. in onCreate()) with:
Bundle bundle = this.getArguments();
if(bundle
!=null){
int myInt = getArguments().getInt(key, defaultValue);
}