Android: Making a sign in page with option to use app without registering/signing in -


this sign in page want create give option use app without signing in or making account. when user chooses this, main page of app have different ui compared when user signed in.

so question is, should make 2 separate activities , layouts, 1 being signed in , other when not signed in. or should use 1 activity , write logic switch out different ui parts?

i'm thinking of going 2 separate activities , layouts since seems more clearer , neater. other version uses less duplication of code. best practice in situation this?

the different layouts won't difficult, think confused on how switch layout, because easiest way.

if(loggedin){ setcontentview(r.layout.loggedinlayout)  }else{ setcontentview(r.layout.notloggedinlayout) } 

you want keep code in oncreate() method. basically, says:

if i'm logged in, lets use layout  otherwise [not logged in] lets use other layout. 

either way, same java code, different layouts!

according dev docs:

...the activity class takes care of creating window in can place ui setcontentview(view)...

so answer question, switching layouts best.

let me know if helpful!


Comments