activit的切换

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了activit的切换相关的知识,希望对你有一定的参考价值。

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1 = (Button) findViewById(R.id.StartAnotherAty); //这里的startAnotherAty是button的ID
b1.setOnClickListener(new Button.OnClickListener() {      //button点击跳转
public void onClick(View v) {                  
Intent intent = new Intent();                //new一个Intent对象,并且指定要启动的class
intent.setClass(MainActivity.this, AnotherAty.class); //anotherAty是新建的activity
startActivity(intent);                    //调用新的class
}
});
}

以上是关于activit的切换的主要内容,如果未能解决你的问题,请参考以下文章