Fragment和Activity之间通信方式有
1、接口(interface),如图
第2种就是在Activity 中new Fragment时
- Fragment fragment = new ItemFragment();
- Bundle args = new Bundle();
- args.putString("arg", TITLE[position]);
- fragment.setArguments(args);
然后在Fragment中
- //获取Activity传递过来的参数
- Bundle mBundle = getArguments();
- String title = mBundle.getString("arg")