20180610
以mimu9的简易计算器为demo
1、布局
①排布
AS提供这几种布局,在这个APP中选择了RelativeLayout为主布局,然后把button放在linearlayout(horizontal)中
这样可以设置为一行一行地编辑各个button,更容易对齐及寻找
②方向锁定
在AndroidMainfest.xml中添加
android:screenOrientation="portrait"
则无论手机如何变动,拥有这个属性的activity都将是竖屏显示。
android:screenOrientation="landscape"横屏显示
2、实例化button
①定义button对应的id的类型
Button btn_0 ;
②实例化
btn_0 = (Button) findViewById(R.id.btn_0) ;
③设置按钮点击事件
btn_0.setOnClickListener(this);
3、点击按钮后
①