Reputation: 3652
Say I have:
private Map<Integer,String> prices = new HashMap<Integer,String>();
private Map<Integer,String> titles = new HashMap<Integer,String>();
private Map<Integer,String> descriptions = new HashMap<Integer,String>();
private Map<Integer,String[]> pictures = new HashMap<Integer,String[]>();
I want to transfer these to another fragment via bundle:
Bundle bundle = new Bundle();
bundle.put //best way?
fragment.setArguments(bundle);
if (fragment != null) {
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.frame_container, fragment).commit();
}
What would be the most efficient/simplest way to do this?
Upvotes: 0
Views: 269
Reputation: 1821
Create a setter of these HashMap
s in your fragment class. then use it to pass these parameters to fragment.
fragment.setHashMaps(Map<Integer,String> prices, Map<Integer,String> titles, Map<Integer,String> descriptions, Map<Integer,String[]> pictures) {
this.prices = prices;
this.titles= titles;
this.descriptions = descriptions;
this.pictures = pictures;
}
Upvotes: 1