开发者

Code to Switch to another java class on android java

开发者 https://www.devze.com 2023-03-28 16:56 出处:网络
I have a java class that loads the first xml layout and the second java class that loads another xml. layout

I have a java class that loads the first xml layout and the second java class that loads another xml. layout If I am about to switch from my fi开发者_如何学Pythonrst java class to the second one using code. How would I do it?


You have to use intents to switch activities.

You can create a new Intent that specifies the class to launch, and fire this intent. This will load your other activity.

Something like:

Intent intent = new Intent(this, OtherClass.class);
startActivity(intent);


Assuming you mean start one Activity from another, you would do the following in Activity1:

Intent intent = new Intent(this, Activity2.class);
startActivity(intent);
0

精彩评论

暂无评论...
验证码 换一张
取 消