码迷,mamicode.com
首页 > 其他好文 > 详细

activit的切换

时间:2016-02-03 01:05:06      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:

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

标签:

原文地址:http://www.cnblogs.com/bycainiao/p/5178829.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!