Reputation: 43349
My application requires 2 screens and for this I have created two different XML
layout files using RelativeLayout
. One layout file loads whenever I run my Activity. Now I want to load the second layout on to the same Activity
, when user click on a button in OptionsMenu
and also when user press Back button the first screen loads instead of exiting the application. So that i don't need to create another Intent
in my application.
Upvotes: 0
Views: 2142
Reputation: 4147
I would suggest a rather simpler means.
Put both your layouts in the single XML and show/gone them appropriately as need be. I dont think u need anything more complicated :-)
Upvotes: 1
Reputation: 3037
Ideally there should be two different activities present in your application. You can add or remove a view component in a view but if you are looking for two completely different screens then i would suggest you to go for a new activity.
I dint get what you meant by "and also when user press Bakc button the first screen loads instead of exiting the application"
If you dont want to show the first screen just finish() the activity.
Upvotes: 3