Switching Views

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Switching Views

Postby Direwolf » Sat Oct 17, 2009 4:50 am

I have just recently egan trying to learn the ows of writting Android apps. I have created a simple applcation that just has 3 buttons on the main laout and a layout for what each buton does. However once I have switched the layout based upon what button was pressed, where does the code for the new layout go? How does one get back to the main layout from the alternate layout?

Thank you in advance,
Dire
Direwolf
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Oct 17, 2009 4:39 am

Top

Postby SlumberMachine » Mon Oct 19, 2009 9:34 pm

Well you could use a view flipper and both layouts go into the same xml file. But. The correct way to handle this in Android is to make seperate activities and call each activity using an intent. Each activity gets its own view xml and java file, but stays in your project folder. You must declare each activity in your manifest. Just make a different activity for each of your main buttons (unless they do something similar in which case you would send the different selection info as a bundle to your intent). Reply if you need more info and I'll post up more later today.
SlumberMachine
Developer
Developer
 
Posts: 39
Joined: Tue Feb 24, 2009 9:00 pm

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 9 guests