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
}
});
}
posted @ 2016-02-03 00:41  KBLW  阅读(155)  评论(0编辑  收藏  举报