2

I have a fragment (Fragment A) and it is not a full screen and I want to open from it another fragment (Fragment B) that fills the whole screen, without knowing the container id

Click on the following link to see an image that clarifies the situation

Fragment A open Fragment B

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

Your activity should manage fragments communication

Often you will want one Fragment to communicate with another, for example to change the content based on a user event. All Fragment-to-Fragment communication is done through the associated Activity. Two Fragments should never communicate directly.

To allow a Fragment to communicate up to its Activity, you can define an interface in the Fragment class and implement it within the Activity. The Fragment captures the interface implementation during its onAttach() lifecycle method and can then call the Interface methods in order to communicate with the Activity. https://developer.android.com/training/basics/fragments/communicating

Community
  • 1
  • 1
Leonardo Velozo
  • 598
  • 1
  • 6
  • 16
  • unfortunately I need only fragment A open fragment B full screen without touching the activity, as I'm making a library that relay only on fragments – Hazem Madkour May 01 '18 at 08:46
  • 1
    not sure if that's possble. Maybe a Fullscreen Dialog will work. But as Leo said, your Activity should manage fragment transactions. If you rely on Fragments, you rely on Activities. – Flo We May 02 '18 at 13:33