1 myButton=(Button)findViewById(R.id.myButton);
2 //监听器加入
3 myButton.setOnClickListener(new MyButtonLintener());
4
5
6 class MyButtonLintener implements OnClickListener
7 {
8
9 @Override
10 public void onClick(View v) {
11 //生成一个Intent对象
12 Intent intent=new Intent();
13
14 intent.putExtra("textIntent", "123");
15 //设置跳转到哪个Activity
16 intent.setClass(HelloWorldActivity.this, OtherActivity.class);
17
18 HelloWorldActivity.this.startActivity(intent);
19
20
21 }
22
23 }