0

I start with a home fragment that opens either a listFragment(Al) or I can choose a normal Fragment(Jim). If my new Fragment(Bob) is called from the listFragment(Al), I want Fragment(Bob) to call XML A. If Fragment(Bob) is called from Fragment(Jim) I want Fragment(Bob) to inflate XML B. How do I pass a value from listFragment(Al) and Fragment(Jim) that can be checked in the onCreateView of Fragment(Bob) so that Fragment(Bob) knows which XML to inflate?

Hope that all makes sense.

Thanks.

Programmer Bruce
  • 64,977
  • 7
  • 99
  • 97
Joshua Sutherland
  • 1,256
  • 4
  • 16
  • 30

1 Answers1

1

Use get/set arguments: http://developer.android.com/reference/android/app/Fragment.html#getArguments()

[edit]

So when you create Fragment Bob from Fragment Jim you could do something like this:

Bob b = Bob.newInstance();
Bundle bundle = new Bundle();
bundle.put("resourceId", R.id.XMLB);
b.setArguemnts(bundle);

or you could even in the newInstance method take in the resourceId

Bob b = new Bob.newInstance(R.id.XMLB);
runor49
  • 3,870
  • 1
  • 21
  • 18