简体   繁体   中英

Change layout xml and working Activity in Android app

I have 2 Activities, MainActivity.java and OtherActivity.java.
According to the Activities I have activity_main.xml and activity_other.xml layouts.

The starting Activity is the MainActivity.java with main.xml.
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.

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" >
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM