I can use Parcelable in Activity but I don\'t know how to use it in Fragment.
I have a ListFragment in FragmentGet to display all rows database in ListView, I want t
Passing data to Fragments
is carried by using Bundles
but not Intents
.
In FragmentSend
change
Intent intent = new Intent(getContext(), FragmentGet.class);
intent.putExtra("Student", model);
Fragment fragmentGet = new FragmentGet();
fragmentGet.setArguments(intent.getExtras());
to this
Fragment fragmentGet = new FragmentGet();
Bundle bundle = new Bundle();
bundle.putParcelable("Student", model);
fragmentGet.setArguments(bundle);
And to receive the data in FragmentGet
change
Bundle bundle = getActivity().getIntent().getExtras();
model = bundle.getParcelable("Student");
to
Bundle bundle = this.getArguments();
if (bundle != null) {
model = bundle.getParcelable("Student");
}