android.widget.Button
1.layout的xml中先设置好button的属性,包括id
<Button android:></Button>

2.在要用到button的Activity中实例化button对象
    Button button1=(Button)findViewById(R.id.button_id);
3.添加监听器
    button1.setOnClickListener(new View.OnClickListener(){
        @override
        public void onClick(View v){}
            //自己的代码
        });

相关文章:

  • 2021-07-04
  • 2022-12-23
  • 2021-08-25
  • 2022-01-15
  • 2022-12-23
  • 2022-01-31
  • 2022-01-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案