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 trialKelvin Warui
Courses Plus Student 878 PointsLoading 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
Courses Plus Student 15,000 PointsHi,
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
Courses Plus Student 878 PointsKelvin Warui
Courses Plus Student 878 PointsAah thanks I did not think of hiding the views I don't want thanks