Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

How to load a different screen/xml file in Java?

I have this app but I want to make it use a different xml view when a button is clicked. I'm new to android development so please help?

1 Answer

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Hi Charlie,

Each "screen" of your app is controlled by an Activity. The look of each Activity is defined by the XML layout file. So when you tap on the button, you want to load a new Activity, which will have a new XML layout associated with it.

We cover this in the Build a Blog Reader project, but you might also find this Quick Tip helpful: Start a New Activity in Android

Thank You Ben. It was really useful I was able to configure my app to use two screens instead of just changing the visibility of my widgets. Thanks