体温登记day1

要求:开发一个手机端上报体温的手机APP,上报内容包括姓名、日期(自动生成)、时间(自动生成)和体温。

首先做了APP的页面,包括编辑框、文本框、按钮及背景图片等,xml文件如下:

复制代码
  1 <?xml version="1.0" encoding="utf-8"?>
  2 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3     xmlns:app="http://schemas.android.com/apk/res-auto"
  4     xmlns:tools="http://schemas.android.com/tools"
  5     android:layout_width="match_parent"
  6     android:layout_height="match_parent"
  7     android:background="@mipmap/bj3"
  8     android:stretchColumns="2"
  9     tools:context=".MainActivity">
 10 
 11     <TableRow
 12         android:layout_width="match_parent"
 13         android:layout_height="match_parent">
 14         <TextView
 15             android:layout_width="wrap_content"
 16             android:layout_height="wrap_content"
 17             android:text="  姓  名:"
 18             android:textSize="18sp" />
 19         <EditText
 20             android:id="@+id/edit_text1"
 21             android:layout_width="280sp"
 22             android:layout_height="wrap_content"
 23             android:hint="请填写姓名"
 24             android:maxLines="1"
 25             android:scrollbars="vertical"
 26             />
 27         <TextView />
 28     </TableRow>
 29     <TableRow>
 30         <TextView
 31             android:layout_width="wrap_content"
 32             android:layout_height="wrap_content"
 33             android:text="  日  期:"
 34             android:layout_marginTop="15dp"
 35             android:textSize="18sp"/>
 36         <TextView
 37             android:id="@+id/textView1"
 38             android:layout_width="match_parent"
 39             android:layout_height="wrap_content"
 40             android:layout_marginTop="15dp"
 41             android:textSize="18sp"/>
 42         <TextView />
 43     </TableRow>
 44     <TableRow>
 45         <TextView
 46             android:layout_width="wrap_content"
 47             android:layout_height="wrap_content"
 48             android:text="  时  间:"
 49             android:layout_marginTop="15dp"
 50             android:textSize="18sp"/>
 51         <TextView
 52             android:id="@+id/textView2"
 53             android:layout_width="match_parent"
 54             android:layout_height="wrap_content"
 55             android:layout_marginTop="15dp"
 56             android:textSize="18sp"/>
 57         <TextView />
 58     </TableRow>
 59 
 60     <TableRow>
 61         <TextView
 62             android:layout_width="wrap_content"
 63             android:layout_height="wrap_content"
 64             android:text="  体  温:"
 65             android:textSize="18sp"/>
 66 
 67         <EditText
 68             android:id="@+id/edit_text3"
 69             android:layout_width="match_parent"
 70             android:layout_height="wrap_content"
 71             android:drawableRight="@mipmap/wd1"
 72             android:hint="请填写体温"
 73             android:maxLines="1"
 74             android:scrollbars="vertical"/>
 75         <TextView />
 76     </TableRow>
 77 
 78     <TableRow>
 79         <TextView
 80             android:layout_width="wrap_content"
 81             android:layout_height="wrap_content"
 82             android:text="  地  点:"
 83             android:textSize="18sp"/>
 84         <EditText
 85             android:id="@+id/edit_text2"
 86             android:layout_width="280sp"
 87             android:layout_height="wrap_content"
 88             android:scrollbars="vertical"
 89             android:onClick="getAddress"
 90             android:hint="点击获取您的位置"
 91             android:minLines="2"
 92             />
 93         <TextView />
 94     </TableRow>
 95         <Button
 96             android:id="@+id/add_data"
 97             android:layout_width="wrap_content"
 98             android:layout_height="wrap_content"
 99             android:background="#328359"
100             android:onClick="insertData"
101             android:text="登  记"
102             android:textColor="#F2F2F2"
103             android:layout_marginTop="20dp"
104             android:textSize="18sp" />
105 
106 </TableLayout>
复制代码

页面效果如下:

原文地址:https://www.cnblogs.com/znjy/p/14884130.html