Is it possible to have two different layouts for different cases in the same activity or do I have to use intent
to call another activity
with a different layout
You can use as many layouts as possible for a single activity but obviously not simultaneously. You can use something like: if (Case_A) setContentView(R. layout.
Yes you can! I had multiple activities inflate the same layout but they save different shared preferences. @Override protected void onCreate(Bundle savedInstanceState) { super. onCreate(savedInstanceState); setContentView(R.
A multi-layout document contains multiple documents, each in its own layout, creating a "book" of documents. Each layout functions as a separate document, with its own grouping, page setup, and so on, but the layouts are generated into a single PDF document.
Yes its possible. You can use as many layouts as possible for a single activity but obviously not simultaneously. You can use something like:
if (Case_A) setContentView(R.layout.layout1); else if (Case_B) setContentView(R.layout.layout2);
and so on...
Yes this is also possible with switch case
I already tried this code....
switch (condition) { case 1: setContentView(R.layout.layout1); break; case 2: setContentView(R.layout.layout2); break; case 3: setContentView(R.layout.layout3); break; default: setContentView(R.layout.main); break; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With