Reputation: 124
I have been searching everywhere but can't seem to find a working example of how to pass a fragment to a fragment that is NOT in the the same activity. Could someone provide me with a great example please?
Upvotes: 3
Views: 6836
Reputation: 7196
You haven't searched anywhere. These two links official site and this. describes how to pass data between fragments. these are the first, two results of a simple google search and this is not a place to come and get the code you want.
Upvotes: -2
Reputation: 12358
Pass data from one fragment activity to another fragment activity.
Actvity 1 Fragment :
Intent intent = new Intent(getActivity(), SecondActivity.class);
intent.putExtra("message", data);
startActivity(intent);
In second activity fragment retrieve in this manner:
SecondActivity activity = (SecondActivity) getActivity();
String data= activity.getIntent().getExtras().getString("message");
Upvotes: 6