1,在fragment中写入以下代码:
Bundle bundle = new Bundle();
bundle.putParcelable("userItem", user);
NavController controller = Navigation.findNavController(v);
controller.navigate(R.id.photoFragment, bundle);
2,在其他fragment中接收:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Bundle bundle = getArguments();
//接收参数
if (bundle != null) {
user = bundle.getParcelable("userItem");
ShowToast.showTextToast(this.getContext(), "获取到数据:" + user.getLargeImageURL());
}
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_photo, container, false);
unbinder = ButterKnife.bind(this, view);
return view;
}