更新时间:2023-12-03 21:30:58
一个新的活动被称为有:
A new Activity is called with:
startActivity(新意图(currentActivity.this,nextActivity.class));
然后在你的新活动的onCreate(捆绑savedInstance)
方法,你可以调用的setContentView(版面布局);
来设置新的布局。
Then in your new Activities onCreate(Bundle savedInstance)
method you can call setContentView(Layout layout);
to set the new Layout.
所以,如果你想在一个点击按钮时,更改活动,你必须做到以下几点:
So if you want to change the Activity when clicking on a Button you have to do the following:
button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
startActivity(new Intent(currentActivity.this, nextActivity.class));
}
});
单击该按钮,当你目前只改变了电流活动的布局的不可以切换到另一个活动。
You are currently only changing the layout of the current Activity when clicking the button and not changing to another Activity.
我希望我正确地理解你。如果没有,那么我提供一些更多的code,所以我可以试着去了解你想做的事情。
I hope I understood you correctly. If not then provide me with some more code so I can try to understand what you want to do.