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.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
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 :-)
Did you try re-calling the setContentView?
Or you may prefer using the ViewFlipper,
Good example here.
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.