android5.0程序开发之按钮控件Button

时间:2024-10-12 04:00:10

1、启动eclipse程序,新建一android5.0工程文件。

android5.0程序开发之按钮控件Button

2、在activity_main.xml文件中改变界面的布局为线性向下布局。不改变的话多个控件会叠加在一起。

android5.0程序开发之按钮控件Button

3、在activity_main.xml文件中加入一个文本控件和两个按钮控件。

android5.0程序开发之按钮控件Button

4、再双击打开MainActivity.java文件,导入TextView控件类和Button控件类声明。

android5.0程序开发之按钮控件Button

5、在程序中加入文本控件和两个按钮控件的引用代码。

android5.0程序开发之按钮控件Button

6、分别增加按钮一和按钮二的执行代码。

android5.0程序开发之按钮控件Button

7、运行程序,分别点击按钮一和按钮二,可见如下效果:

android5.0程序开发之按钮控件Button
android5.0程序开发之按钮控件Button
© 手抄报圈