0

I have this nested fragment:

-> = host

MainActivity -> Fragment A -> Fragment B -> Fragment C

but when i'm trying to getParentFragment() from Fragment C , i'm getting Fragment A instead of Fragment B. I will be very thankful if someone can explain this and show me the solution.

this is how i call getParentFragment from fragment C

FragmentB mContext = (FragmentB) getParentFragment();
Fahmi Sidik
  • 189
  • 5
  • 13

1 Answers1

2

I found the solution:

In the Fragment B you have to use: getChildFragmentManager() when you create the Fragment C

toni
  • 1,674
  • 1
  • 15
  • 15
  • Solved my problem of FragmentB's being placed in very first instance of FragmentA, instead of subsequent ones too. Thanks! – Mike Hall Jan 31 '18 at 04:12