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的切换)