0

I got a little problem in Android. I am creating a App and want to pass a Object to my Fragment. I'm searching for a way to pass a custom Object to my Fragment, something like:

Fragment frag = new myFragment();
   Bundle args = new Bundle();
   args.put("Arg1", myObject);

Is there a way to do something like that?

Thanks!

MDoe
  • 3
  • 3
  • Possible duplicate of [Pass ArrayList from Activity to ListFragment?](http://stackoverflow.com/questions/10265352/pass-arraylist-from-activity-to-listfragment) – K Neeraj Lal Nov 26 '16 at 16:31
  • You have to pass that values using bundle, add values to bundle and then add that bundle using frag.setArgument, next get that values in that fragment using geArguments method, Hope this will help you – Bhavnik Nov 26 '16 at 16:32
  • @Bhavnik i forgot the bundle, sorry about that. My problem is that i don't know if there is a way to pass custom object as an Argument – MDoe Nov 26 '16 at 16:38

1 Answers1

0

Getters and setters are good for this job rather than using arguments when you pass object between two fragments

Answer is given in this link Android: Passing Objects Between Fragments

Community
  • 1
  • 1
Jayakrishnan
  • 4,457
  • 29
  • 29