你的位置:首页 > 操作系统

[操作系统]两个Fragment之间传递数据


1.第一个Fragment 

BlankFragment blankFragment = new BlankFragment();
Bundle bundle = new Bundle();
bundle.putString("one", "one");
bundle.putString("two", "two");
blankFragment.setArguments(bundle);
getFragmentManager().beginTransaction().replace(R.id.container, blankFragment).addToBackStack(null).commit();

2.第二个Fragment 

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_blank, container, false);
Bundle bundle = getArguments();

String string = bundle.getString("one");
String string1 = bundle.getString("two");

Log.e("000000000000", string+string1);
return view;
}