0
I have a Activity
that the email is requested and if the email exists I show a Activity
with a Fragment
for entering the password. If this email n exists, I want to display a Fragment
, in this same Activity
, to make a record.
My question is:
How to choose which Fragment
will be inflated ? How can I do this?
Each fragment is represented by a distinct class and layout. No error. You might think of it as a Fragment being a piece of a screen that will temporarily superimpose Activity.
– Mr_Anderson
@Mr_anderson thank you, I will inflate them, in another Activity, in this case step to the Bundle of Activity the parameters and depending on what get I do the setcontentview to the correct Fragment , in the onCreate of Activity in question?
– Henrique
Voce can receive a boolean parameter in Activity #2, type temCadastro. Make an if in Activity nº2 --- if(temCadastro == true) {typeSenha();} Else {displayCadastro();} Inside typeSend and moostraCarting you inflate the fragment, not the xml layout of the fragment. Important to note that I find it more efficient to create a class for the fragment and not merely to change the layout.
– Mr_Anderson
The logical test if you have registered is done in Activity nº2 (the xml of this Activity will be "blank"). Activity decides which fragment to launch based on the temCadastro logic test.. The fragment will "sprout" on top of the Activity (the fragment consists of a specific class of fragment+xml). The interesting thing to note is that the fragment is different from a pop-up, known as dialog.
– Mr_Anderson
@Mr_anderson got it. Put as answer that mark. Thank you.
– Henrique