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);
精彩评论