按钮(Button)

按钮是使用的最多的按键,在Android中使用Button来显示。按钮在点击之后也必然要触发一个时间,所以需要对Button设置一个事件监听器。使用Button这个组件首先需要在xml布局文件中声明这个组件,然后在代码 中通过ID引用这个组件,之后设置对应的监听器实现必须的功能 。

        //取得Button对象
        m_Button1=(Button)findViewById(R.id.Button1);     
        //设置按钮嗦显示的文字
        m_Button1.setText("开始");       
        //设置按钮的宽度
        m_Button1.setWidth(150);   
        //设置文字的颜色
        m_Button1.setTextColor(Color.GREEN);       
        //设置文字的大小尺寸
        m_Button1.setTextSize(30);

 

源码下载链接:http://www.apkbus.com/android-117097-1-1.html


喜欢开源,乐意分享的大神们,欢迎加入QQ群:176507146,你值得拥有哦!

相关文章:

  • 2021-07-16
  • 2021-07-31
  • 2022-01-21
  • 2021-06-27
  • 2021-08-13
  • 2021-07-27
  • 2021-06-30
  • 2021-10-30
猜你喜欢
  • 2021-08-06
  • 2021-09-17
  • 2022-02-25
  • 2021-06-24
  • 2021-11-30
  • 2021-11-04
  • 2021-10-25
相关资源
相似解决方案