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 }

相关文章:

  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-07
  • 2021-08-08
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案