[英]Change layout xml and working Activity in Android app
I have 2 Activities, MainActivity.java and OtherActivity.java. 我有2个活动,MainActivity.java和OtherActivity.java。
According to the Activities I have activity_main.xml and activity_other.xml layouts. 根据活动,我有activity_main.xml和activity_other.xml布局。
The starting Activity is the MainActivity.java with main.xml. 起始活动是带有main.xml的MainActivity.java。
I want a menu to swap the active activity and layout to the other. 我希望菜单将活动活动和布局交换到其他菜单。
I tried it with sharedPreferences and activate the other but it didn't work for me. 我尝试使用sharedPreferences并激活了另一个,但是对我来说不起作用。
Use code below to start another activity. 使用下面的代码开始另一个活动。
Intent intent = new Intent(MainActivity.this, OtherActivity.class);
startActivity(intent);
Use below to let one activity only have one instance. 在下面使用,让一个活动只有一个实例。
<activity
...
android:launchMode="singleInstance" >
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.