先来一张思维导图
今天给大家分享一个简易计算器,出来效果图如下图:确定按钮下面是有一个文本框的,我没设置填充色所以看不出来
首先我们去xml把样式做出来,并给除确定按钮外所有的控件设置一个id, 给按钮写一个onClick事件,源代码如下:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入数字" android:textSize="20sp" android:id="@+id/et_deng_name1" /> <RadioGroup android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/rg_deng_d" > <RadioButton android:layout_width="wrap_content"