I’m writing an application which I want to be able to launch a second class with a different layout when a menu button is pressed. the code I have to switch classes is:
case Menubutton1:
Intent i = new Intent(Budgeter.this, Outgoings.class);
startActivity(i);
return true;
(Obviously within a case statement)
How do I create an xml file which only relates to the second class? Also do I need to edit AndroidManifest.xml?
Finally if anyone could point me towards some good tutorials on intents I would greatly appreciate it.
I’m guessing here that you’re confused about thinking the layout file for an Activity has to be called main.xml??? If so, this is not the case…
You can have
budgeter.xml,outgoings.xmletc etc.Just use
setContentView(R.layout.budgeter)in the Budgeter Activity’sonCreate(...)method andsetContentView(R.layout.outgoings)in the Outgoings ActivityonCreate(...)and so on.Yes, all Activities must be registered in AndroidManifest.xml
As for working with Intents, try this as a starter…
Intents and Intent Filters