有谁知道如何按下按钮并转到我以前的布局之一吗?
public class Main extends Activity {
private Button button_back;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button_back = (Button) findViewById(R.id.button1);
button_back.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
setContentView(R.layout.back);
Intent intent = new Intent(Main.this, Back.class);
startActivity(intent);
}
});
这是主要思想,但 android 也不能识别我的按钮类型
最佳答案
你必须使用Intent
。
简单
Intent intent = new Intent();
intent.setClass(this, Other_Activity.class);
startActivity(intent;
试试这个 http://www.vogella.com/articles/AndroidIntent/article.html
关于java - 按下按钮并转到上一个布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20444590/