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

Kelvin Warui
PLUS
Kelvin Warui
Courses Plus Student 878 Points

Loading different pages with different views but using the same layout

In the interactive story app we saw how we can create a page class to load different pages but with the same views in the xml layout.My question is how would i load different pages also but now using diffirent views using the same layout file.For example one page might have an image and a button the other page might have five edit text boxes an image and a button the other page might have a listView and so on

1 Answer

Rares Conea
PLUS
Rares Conea
Courses Plus Student 15,000 Points

Hi,

An easy way would be to use a ViewFlipper, you can search for it on google and you ll find plenty of examples. Another way of doing what you want but one that requires more code is to define all the views(TextView, EditText and so on) you want in the layout of the MainActivity and set their visibility to GONE or VISIBLE at your choice.

Kelvin Warui
Kelvin Warui
Courses Plus Student 878 Points

Aah thanks I did not think of hiding the views I don't want thanks