Reputation: 1179
I have a nav fragment and a content fragment. I want to be able to pass a bundle, and reload the fragment based on fragment interactions. I've seen people say use .setArguments()
, but it's not letting me use said method. Any advice?
public void onStockFragmentInteraction(String stock) {
Bundle bundle = new Bundle();
bundle.putString("stock", stock);
getFragmentManager()
.beginTransaction()
.replace(R.id.content, new StoryFragment())
.addToBackStack(null)
.commit();
}
Upvotes: 1
Views: 209
Reputation: 157457
setArguments
is a method of Fragment
not of FragmentManager
StoryFragment f = new StoryFragment()
f.setArguments(bundle);
getFragmentManager()
.beginTransaction()
.replace(R.id.content, f)
.addToBackStack(null)
.commit();
keep a reference to the fragment and call setArguments
on the instance before submitting it on the transaction
Upvotes: 2