20210310日报

体温登记

 

1、由于疫情的原因,在家上网课,老师留作业,开发一个体温登记的小软件。

2、截图

(1)首页

 

(2)添加体温页面

 

(3)浏览体温页面

 

(4)添加用户页面

 

5)切换用户页面

 

6)体温上报统计页面

 

3、源码

(1)MainActivity

 

package com.example.tiwen2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    Button bt_addtiwen,bt_showtiwen,bt_adduser,bt_changeuser,bt_tongji,bt_new;
    Intent intent;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        bt_addtiwen=(Button)findViewById(R.id.bt_addtiwen);
        bt_showtiwen=(Button)findViewById(R.id.bt_showtiwen);
        bt_adduser=(Button)findViewById(R.id.bt_adduser);
        bt_changeuser=(Button)findViewById(R.id.bt_changeuser);
        bt_tongji=(Button)findViewById(R.id.bt_tongji);
        bt_new=(Button)findViewById(R.id.bt_new);

        bt_addtiwen.setOnClickListener(this);
        bt_showtiwen.setOnClickListener(this);
        bt_adduser.setOnClickListener(this);
        bt_changeuser.setOnClickListener(this);
        bt_tongji.setOnClickListener(this);
        bt_new.setOnClickListener(this);

        MyopenHelper helper = new MyopenHelper(this,"user.db",null,1);
        SQLiteDatabase readableDatabase = helper.getReadableDatabase();
        String sql = "select * from user where status = 1";
        Cursor curor = readableDatabase.rawQuery(sql , null);
        int count=0;
        if(curor.moveToFirst()){//遍历查询到的结果
            do{
                //创建person对象
                UserBean userBean=new UserBean();
                //根据列名 name 获取数据库中对应的值
                String name = curor.getString(curor.getColumnIndex("name"));
                //根据列名 phone 获取数据库中对应的值
                String id = curor.getString(curor.getColumnIndex("id"));
                String phone = curor.getString(curor.getColumnIndex("phone"));
                //设置相应数据
                userBean.setName(name);
                userBean.setId(id);
                userBean.setPhone(phone);
                count++;
            }while(curor.moveToNext());
        }
        curor.close();
        if(count==0){
            intent = new Intent(MainActivity.this,UserActivity.class);
            startActivity(intent);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_addtiwen:
                intent = new Intent(MainActivity.this,TiWenActivity.class);
                startActivity(intent);
                break;
            case R.id.bt_showtiwen:
                intent = new Intent(MainActivity.this,ShowTiWenActivity.class);
                startActivity(intent);
                break;
            case R.id.bt_adduser:
                intent = new Intent(MainActivity.this,UserActivity.class);
                startActivity(intent);
                break;
            case R.id.bt_changeuser:
                intent = new Intent(MainActivity.this,ShowUserActivity.class);
                startActivity(intent);
                break;
            case R.id.bt_tongji:
                intent = new Intent(MainActivity.this,TongJiActivity.class);
                startActivity(intent);
                break;
            case R.id.bt_new:
                intent = new Intent(MainActivity.this,NewExcelActivity.class);
                startActivity(intent);
                break;
        }
    }
}

 

(2)MyopenHelper

package com.example.tiwen2;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MyopenHelper extends SQLiteOpenHelper {
    public MyopenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql="Create table tiwen (name text,time text,space text,wen text,teshu text)";
        db.execSQL(sql);
        String sql2="Create table user (name text,id text,phone text,status text)";
        db.execSQL(sql2);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}

(3)NewExcelActivity

package com.example.tiwen2;

import android.inputmethodservice.Keyboard;
import android.os.Bundle;
import android.os.Environment;

import androidx.appcompat.app.AppCompatActivity;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class NewExcelActivity extends AppCompatActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_newexcel);

        initWorkbook(Environment.getExternalStorageDirectory()+"/text.xlsx");

    }

    private static void initWorkbook(String path) {
        Workbook mExcelWorkbook = new HSSFWorkbook();
        //标题栏单元格特征
//        CellStyle titleStyle = createTitleCellStyle();

        //创建execl中的一个表
        Sheet sheet = mExcelWorkbook.createSheet();
        mExcelWorkbook.setSheetName(0, "mi-cms-test");
        //创建标题栏1
        Row titleRow1 = sheet.createRow(0);
        // 设置标题栏高度
        titleRow1.setHeightInPoints(60);
//        titleRow1.setRowStyle(titleStyle);

        //创建标题栏第1个标题
        Cell cell0 = titleRow1.createCell(0);
        cell0.setCellValue("");

        //创建标题栏第2个标题
        Cell cell1 = titleRow1.createCell(1);
        cell1.setCellValue("信号强度");
        sheet.addMergedRegion(CellRangeAddress.valueOf("$B$1:$D$1"));

        //创建标题栏第3个标题
        Cell cell2 = titleRow1.createCell(4);
        cell2.setCellValue("数据包");
        sheet.addMergedRegion(CellRangeAddress.valueOf("$E$1:$G$1"));

        //创建标题栏第4个标题
        Cell cell3 = titleRow1.createCell(7);
        cell3.setCellValue("");

        //创建标题栏第5个标题
        Cell cell4 = titleRow1.createCell(8);
        cell4.setCellValue("心率");
        sheet.addMergedRegion(CellRangeAddress.valueOf("$I$1:$J$1"));

        //创建标题栏2
        Row titleRow2 = sheet.createRow(1);
        // 蓝牙地址/序列号
        Cell cell10 = titleRow2.createCell(0);
        cell10.setCellValue("蓝牙地址,序列号");

        // 信号强度
        Cell cell11 = titleRow2.createCell(1);
        cell11.setCellValue("最小");
        Cell cell12 = titleRow2.createCell(2);
        cell12.setCellValue("最大");
        Cell cell13 = titleRow2.createCell(3);
        cell13.setCellValue("平均");

        // 数据包
        Cell cell14 = titleRow2.createCell(4);
        cell14.setCellValue("总计");
        Cell cell15 = titleRow2.createCell(5);
        cell15.setCellValue("丢失数");
        Cell cell16 = titleRow2.createCell(6);
        cell16.setCellValue("丢失率");

        // 电量
        Cell cell17 = titleRow2.createCell(7);
        cell17.setCellValue("电量");

        // 心率
        Cell cell18 = titleRow2.createCell(8);
        cell18.setCellValue("最大");
        Cell cell19 = titleRow2.createCell(9);
        cell19.setCellValue("最小");

        writeFile(mExcelWorkbook, path);
    }

    /**
     * 将Excle表格写入文件中
     *
     * @param workbook
     * @param fileName
     */
    private static void writeFile(Workbook workbook, String fileName) {
        FileOutputStream outputStream = null;
        try {
            outputStream = new FileOutputStream(new File(fileName));
            workbook.write(outputStream);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (outputStream != null) {
                    outputStream.close();
                }
                if (workbook != null) {
                    workbook.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static void getWorkbook(String filename) throws IOException {
        if (null != filename) {
            String fileType = filename.substring(filename.lastIndexOf("."),
                    filename.length());
            FileInputStream fileStream = new FileInputStream(new File(filename));
            if (".xls".equals(fileType.trim().toLowerCase())) {
                Workbook mExcelWorkbook = new HSSFWorkbook(fileStream);// 创建 Excel 2003 工作簿对象
            }
        }
    }

}

(4)ShowTiWenActivity

package com.example.tiwen2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;

public class ShowTiWenActivity extends AppCompatActivity {
    /*
    将数据库中的数据展示出来
     */
    private ListView lv_list;
    private ArrayList<WenBean> wenBeans = new ArrayList<WenBean>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show);

        lv_list = (ListView)findViewById(R.id.lv_list);
        MyopenHelper helper = new MyopenHelper(this,"user.db",null,1);
        SQLiteDatabase readableDatabase = helper.getReadableDatabase();
        String sql = "select * from user where status = 1";
        Cursor curor = readableDatabase.rawQuery(sql , null);
        //遍历查询到的结果
        int count=0;
        String name0="";
        if(curor.moveToFirst()){
            do{
                name0 = curor.getString(curor.getColumnIndex("name"));
                count++;
            }while(curor.moveToNext());
        }
        curor.close();
        helper = new MyopenHelper(this,"tiwen.db",null,1);
        readableDatabase = helper.getReadableDatabase();
        sql = "select * from tiwen where name = '" + name0 + "'";
        curor = readableDatabase.rawQuery(sql , null);
        count=0;
        //遍历查询到的结果
        if(curor.moveToFirst()){
            do{
                //创建person对象
                WenBean wenBean = new WenBean();
                //根据列名 name 获取数据库中对应的值
                String name = curor.getString(curor.getColumnIndex("name"));
                //根据列名 phone 获取数据库中对应的值
                String time = curor.getString(curor.getColumnIndex("time"));
                String space = curor.getString(curor.getColumnIndex("space"));
                String wen = curor.getString(curor.getColumnIndex("wen"));
                String teshu = curor.getString(curor.getColumnIndex("teshu"));
                //设置相应数据
                wenBean.setName(name);
                wenBean.setTime(time);
                wenBean.setSpace(space);
                wenBean.setWen(wen);
                wenBean.setTeshu(teshu);
                //把数据添加到集合
                wenBeans.add(wenBean);
                count++;
            }while(curor.moveToNext());
        }
        curor.close();
        //list显示
        //把数据适配器和listview绑定
        lv_list.setAdapter(new MyAdapter());
        //关闭游标
        curor.close();
        helper.close();
        if(count!=0) {
            Toast.makeText(this, "查询成功", Toast.LENGTH_SHORT).show();
        }else {
            Toast.makeText(this, "查询失败", Toast.LENGTH_SHORT).show();
        }
        lv_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //点击跳转
                Intent intent =new Intent(ShowTiWenActivity.this,MainActivity.class);
                //启动填写页面
                startActivity(intent);
            }
        });
    }
    private class MyAdapter extends BaseAdapter {

        //返回要展示的数据集合的条目数
        @Override
        public int getCount() {
            return wenBeans.size();
        }
        //通过adapter传进来的posion(listview中条目的position)
        //把它对应的数据集合中的对象返回来
        @Override
        public Object getItem(int position) {
            return wenBeans.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            //①把布局文件转换为View对象 需要判断convertView是否为空
            View view= null;
            if(convertView == null){
                //创建view对象
                view = View.inflate(ShowTiWenActivity.this, R.layout.content_tiwen, null);
            }else{
                //复用旧的convertView
                view = convertView;
            }
            //②找到要修改的控件的对象  注意要调用view.findViewById
            TextView tv_name = (TextView)view.findViewById(R.id.tv_name);
            TextView tv_time = (TextView)view.findViewById(R.id.tv_time);
            TextView tv_space = (TextView)view.findViewById(R.id.tv_space);
            TextView tv_wen = (TextView)view.findViewById(R.id.tv_wen);
            TextView tv_teshu = (TextView)view.findViewById(R.id.tv_teshu);

            //③ 设置数据
            //3.1通过position 到数据集合中把要显示的数据找到
            WenBean wenBean = wenBeans.get(position);
            //3.2把要显示的内容展示到对应的View对象上
            tv_name.setText("姓名:"+wenBean.getName());
            tv_time.setText("时间:"+wenBean.getTime());
            tv_space.setText("地址:"+wenBean.getSpace());
            tv_wen.setText("体温:"+wenBean.getWen()+"度");
            tv_teshu.setText("特殊情况:"+wenBean.getTeshu());
            return view;
        }
    }
}

(5)ShowUserActivity

package com.example.tiwen2;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;

public class ShowUserActivity extends AppCompatActivity {

    private ListView lv_list;
    private ArrayList<UserBean> userBeans = new ArrayList<UserBean>();
    private MyopenHelper helper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show);

        lv_list = (ListView)findViewById(R.id.lv_list);
        helper = new MyopenHelper(this,"user.db",null,1);
        SQLiteDatabase readableDatabase = helper.getReadableDatabase();
        String sql = "select * from user";
        Cursor curor = readableDatabase.rawQuery(sql , null);
        int count=0;
        //遍历查询到的结果
        if(curor.moveToFirst()){
            do{
                //创建person对象
                UserBean userBean=new UserBean();
                //根据列名 name 获取数据库中对应的值
                String name = curor.getString(curor.getColumnIndex("name"));
                //根据列名 phone 获取数据库中对应的值
                String id = curor.getString(curor.getColumnIndex("id"));
                String phone = curor.getString(curor.getColumnIndex("phone"));
                String status = curor.getString(curor.getColumnIndex("status"));
                //设置相应数据
                userBean.setName(name);
                userBean.setId(id);
                userBean.setPhone(phone);
                userBean.setStatus(status);
                //把数据添加到集合
                userBeans.add(userBean);
                count++;
            }while(curor.moveToNext());
        }
        curor.close();
        //list显示
        //把数据适配器和listview绑定
        lv_list.setAdapter(new ShowUserActivity.MyAdapter());
        //关闭游标
        curor.close();
        helper.close();
//        if(count!=0) {
//            Toast.makeText(this, "查询成功", Toast.LENGTH_SHORT).show();
//        }else {
//            Toast.makeText(this, "查询失败", Toast.LENGTH_SHORT).show();
//        }
        lv_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //点击跳转
                Intent intent =new Intent(ShowUserActivity.this,MainActivity.class);
                //启动填写页面
                startActivity(intent);
            }
        });
    }
    private class MyAdapter extends BaseAdapter {

        //返回要展示的数据集合的条目数
        @Override
        public int getCount() {
            return userBeans.size();
        }
        //通过adapter传进来的posion(listview中条目的position)
        //把它对应的数据集合中的对象返回来
        @Override
        public Object getItem(int position) {
            return userBeans.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            //①把布局文件转换为View对象 需要判断convertView是否为空
            View view= null;
            if(convertView == null){
                //创建view对象
                view = View.inflate(ShowUserActivity.this, R.layout.content_user, null);
            }else{
                //复用旧的convertView
                view = convertView;
            }
            //②找到要修改的控件的对象  注意要调用view.findViewById
            TextView tv_text = (TextView)view.findViewById(R.id.tv_text);

            //③ 设置数据
            //3.1通过position 到数据集合中把要显示的数据找到
            UserBean userBean = userBeans.get(position);
            //3.2把要显示的内容展示到对应的View对象上
            tv_text.setText("姓名:"+userBean.getName()+",电话:"+userBean.getPhone());
            Log.e("TRE",userBean.getStatus());
            Button bt_change = (Button)view.findViewById(R.id.bt_change);
            if("0".equals(userBean.getStatus())){
                bt_change.setVisibility(View.VISIBLE);
                Log.e("TRE","提交监听开始执行");
                bt_change.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        SQLiteDatabase readableDatabase = helper.getReadableDatabase();
                        String sql = "select * from user where status = 1";
                        Cursor curor = readableDatabase.rawQuery(sql , null);
                        //遍历查询到的结果
                        int count=0;
                        String name1="";
                        if(curor.moveToFirst()){
                            do{
                                name1 = curor.getString(curor.getColumnIndex("name"));
                                count++;
                            }while(curor.moveToNext());
                        }
                        curor.close();

                        String name2=userBean.getName();
                        readableDatabase = helper.getReadableDatabase();
                        String sql1 = "update user set status = 0 where name = '" + name1 + "'";
                        String sql2 = "update user set status = 1 where name = '" + name2 + "'";
                        readableDatabase.execSQL(sql1);
                        readableDatabase.execSQL(sql2);
                        readableDatabase.close();
                        Toast.makeText(ShowUserActivity.this, "切换成功!", Toast.LENGTH_SHORT).show();
                        Intent intent = new Intent(ShowUserActivity.this, ShowUserActivity.class);
                        finish();//结束当前活动
                        startActivity(intent);
                    }
                });
            }
            return view;
        }
    }

}

(6)TiWenActivity

package com.example.tiwen2;

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.core.app.ActivityCompat;

import java.io.IOException;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;

public class TiWenActivity extends Activity implements View.OnClickListener {
    MyopenHelper helper;
    Button bt_insert;
    EditText et_wen,et_2,et_3,et_4,et_5;
    TextView tv_name,tv_time,tv_space;
    CheckBox cb_1,cb_2,cb_3,cb_4,cb_5;
    private static final String[] authBaseArr = {//申请类型
            Manifest.permission.ACCESS_FINE_LOCATION,
            Manifest.permission.ACCESS_COARSE_LOCATION
    };
    private static final int authBaseRequestCode = 1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tiwen);
        bt_insert=(Button)findViewById(R.id.bt_insert);
        tv_name=(TextView)findViewById(R.id.tv_name);
        tv_time=(TextView)findViewById(R.id.tv_time);
        tv_space=(TextView)findViewById(R.id.tv_space);
        et_wen=(EditText)findViewById(R.id.et_wen);
        et_2=(EditText)findViewById(R.id.et_2);
        et_3=(EditText)findViewById(R.id.et_3);
        et_4=(EditText)findViewById(R.id.et_4);
        et_5=(EditText)findViewById(R.id.et_5);
        cb_1=(CheckBox)findViewById(R.id.cb_1);
        cb_2=(CheckBox)findViewById(R.id.cb_2);
        cb_3=(CheckBox)findViewById(R.id.cb_3);
        cb_4=(CheckBox)findViewById(R.id.cb_4);
        cb_5=(CheckBox)findViewById(R.id.cb_5);

        cb_1.setOnClickListener(this);
        cb_2.setOnClickListener(this);
        cb_3.setOnClickListener(this);
        cb_4.setOnClickListener(this);
        cb_5.setOnClickListener(this);
        bt_insert.setOnClickListener(this);


        MyopenHelper helper = new MyopenHelper(this,"user.db",null,1);
        SQLiteDatabase readableDatabase = helper.getReadableDatabase();
        String sql = "select * from user where status = 1";
        Cursor curor = readableDatabase.rawQuery(sql , null);
        //遍历查询到的结果
        int count=0;
        String name="";
        if(curor.moveToFirst()){
            do{
                name = curor.getString(curor.getColumnIndex("name"));
                count++;
            }while(curor.moveToNext());
        }
        curor.close();
        tv_name.setText(name);

        SimpleDateFormat simpleDateFormat;
        Date date = new Date();
        simpleDateFormat=new SimpleDateFormat("yyyy年MM月dd日HH:mm");
        String time=simpleDateFormat.format(date);
        tv_time.setText(time);

        LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

        initNavi();

        //权限检查的代码
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            return;
        }
        locationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER,//指定GPS定位提供者
                1000,//指定数据更新的间隔时间
                1,//位置间隔的距离为1m
                new LocationListener() {//监听GPS信息是否改变
                    @Override
                    public void onLocationChanged(Location location) {//GPS信息发送改变时回调
                        Log.i("lgq","onLocationChanged===="+location.getProvider());
                    }

                    @Override
                    public void onStatusChanged(String provider, int status, Bundle extras) {//GPS状态发送改变时回调

                    }

                    @Override
                    public void onProviderEnabled(String provider) { //定位提供者启动时回调

                    }

                    @Override
                    public void onProviderDisabled(String provider) { //定位提供者关闭时回调

                    }
                }
        );
        Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);//获取最新的定位信息
        if (location==null){
            locationManager.requestLocationUpdates(
                    LocationManager.NETWORK_PROVIDER,//指定GPS定位提供者
                    5000,//指定数据更新的间隔时间
                    10,//位置间隔的距离为1m
                    new LocationListener() {//监听GPS信息是否改变
                        @Override
                        public void onLocationChanged(Location location) {//GPS信息发送改变时回调
                            Log.i("lgq","onLocationChanged===="+location.getProvider());
                        }

                        @Override
                        public void onStatusChanged(String provider, int status, Bundle extras) {//GPS状态发送改变时回调

                        }

                        @Override
                        public void onProviderEnabled(String provider) { //定位提供者启动时回调

                        }

                        @Override
                        public void onProviderDisabled(String provider) { //定位提供者关闭时回调

                        }
                    }
            );
            location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);//获取最新的定位信息
        }
        locationUpdates(location);
    }

    @Override
    public void onClick(View v) {
        String wen=et_wen.getText().toString();
        String teshu="";
        if(cb_2.isChecked()||cb_3.isChecked()||cb_4.isChecked()||cb_5.isChecked()){
            cb_1.setChecked(false);
        }
        else{
            cb_1.setChecked(true);
        }
        if(cb_2.isChecked()){
            et_2.setVisibility(View.VISIBLE);
        }
        else {
            et_2.setVisibility(View.GONE);
        }
        if(cb_3.isChecked()){
            et_3.setVisibility(View.VISIBLE);
        }
        else {
            et_3.setVisibility(View.GONE);
        }
        if(cb_4.isChecked()){
            et_4.setVisibility(View.VISIBLE);
        }
        else {
            et_4.setVisibility(View.GONE);
        }
        if(cb_5.isChecked()){
            et_5.setVisibility(View.VISIBLE);
        }
        else {
            et_5.setVisibility(View.GONE);
        }

        if(!"2、".equals(et_2.getText().toString())){
            teshu=et_2.getText().toString();
        }
        else if(!"3、".equals(et_3.getText().toString())){
            teshu=et_3.getText().toString();
        }
        else if(!"4、".equals(et_4.getText().toString())){
            teshu=et_4.getText().toString();
        }
        else if(!"5、".equals(et_5.getText().toString())){
            teshu=et_5.getText().toString();
        }
        else{
            teshu="1、无";
        }

        switch (v.getId()) {
            case R.id.bt_insert:
                String name = tv_name.getText().toString();
                String time=tv_time.getText().toString();
                String space=tv_space.getText().toString();
                if (TextUtils.isEmpty(wen)) {
                    Toast.makeText(TiWenActivity.this, "体温不能为空", Toast.LENGTH_SHORT).show();
                }
                else {
                    String sql = "insert into tiwen (name,time,space,wen,teshu) values('" + name + "','" + time +  "','" + space + "','" + wen + "','" + teshu + "')";
                    helper = new MyopenHelper(this, "tiwen.db", null, 1);
                    SQLiteDatabase readableDatabase = helper.getReadableDatabase();
                    readableDatabase.execSQL(sql);
                    readableDatabase.close();
                    Toast.makeText(TiWenActivity.this, "提交成功!", Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent(TiWenActivity.this, MainActivity.class);
                    finish();//结束当前活动
                    startActivity(intent);
                }
                break;
        }
    }
    private boolean hasBasePhoneAuth() {
        PackageManager pm = getPackageManager();
        for (String auth : authBaseArr) {
            if (pm.checkPermission(auth, getPackageName()) != PackageManager.PERMISSION_GRANTED) {
                return false;
            }
        }
        return true;
    }

    private void initNavi() {
        // 申请权限
        if (android.os.Build.VERSION.SDK_INT >= 23) {
            if (!hasBasePhoneAuth()) {
                this.requestPermissions(authBaseArr, authBaseRequestCode);
                return;
            }
        }
    }

    public void locationUpdates(Location location){
        if(location != null){
            StringBuilder stringBuilder = new StringBuilder(); //构建一个字符串构建器,用于记录定位信息
            stringBuilder.append("经度:");
            stringBuilder.append(location.getLongitude());
            stringBuilder.append("
纬度:");
            stringBuilder.append(location.getLatitude());
            String ab = getAddress(location.getLatitude(),location.getLongitude());
            tv_space.setText(ab);
        }
        else{
            tv_space.setText("GPS失效啦!");
        }
    }

    public String getAddress(double latitude, double longitude) {
        Geocoder geocoder = new Geocoder(this, Locale.getDefault());
        try {
            List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
            if (addresses.size() > 0) {
                Address address = (Address) ((List) addresses).get(0);
                String data = address.toString();
                int startSpace = data.indexOf(""") + ":".length();
                int endSpace = data.indexOf(""", startSpace);
                String space=data.substring(startSpace,endSpace);
                return space;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "获取失败!";
    }
}

(7)TongJiActivity

package com.example.tiwen2;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class TongJiActivity extends AppCompatActivity {

    TextView tv_renshu,tv_renshu1,tv_renshu2,tv_zheng,tv_yi,tv_chang;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tongji);

        tv_renshu=(TextView)findViewById(R.id.tv_renshu);
        tv_renshu1=(TextView)findViewById(R.id.tv_renshu1);
        tv_renshu2=(TextView)findViewById(R.id.tv_renshu2);
        tv_zheng=(TextView)findViewById(R.id.tv_zheng);
        tv_yi=(TextView)findViewById(R.id.tv_yi);
        tv_chang=(TextView)findViewById(R.id.tv_chang);

        SimpleDateFormat simpleDateFormat;
        Date date = new Date();
        simpleDateFormat=new SimpleDateFormat("yyyy年MM月dd日");
        String time=simpleDateFormat.format(date);

        MyopenHelper helper1 = new MyopenHelper(this, "tiwen.db", null, 1);
        SQLiteDatabase readableDatabase1 = helper1.getReadableDatabase();
        String sql1="";
        MyopenHelper helper = new MyopenHelper(this, "user.db", null, 1);
        SQLiteDatabase readableDatabase = helper.getReadableDatabase();
        String sql = "select * from user";
        Cursor cursor = readableDatabase.rawQuery(sql , null);
        int count=0,count1=0,count2=0,count3=0;
        if(cursor.moveToFirst()){
            do{
                count++;
                String name = cursor.getString(cursor.getColumnIndex("name"));
                sql1="select * from tiwen where name = '" + name + "' and time like '%" + time + "%'";
                Cursor cursor1=readableDatabase1.rawQuery(sql1,null);
                if(cursor1.moveToFirst()) {
                    String wen=cursor1.getString(cursor1.getColumnIndex("wen"));
                    String teshu=cursor1.getString(cursor1.getColumnIndex("teshu"));
                    if(wen.compareTo("36")>0&&wen.compareTo("37")<0){
                        count2++;
                    }
                    if(!"1、无".equals(teshu)){
                        count3++;
                    }
                    count1++;
                }
                cursor1.close();
            }while(cursor.moveToNext());

        }
        cursor.close();
        tv_renshu.setText(""+count+"人");
        tv_renshu1.setText(""+count1+"人");
        tv_renshu2.setText(""+(count-count1)+"人");
        tv_zheng.setText(""+(count2-count3)+"人");
        tv_yi.setText(""+count3+"人");
        tv_chang.setText(""+(count1-count2)+"人");
    }
}

(8)UserActivity

package com.example.tiwen2;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class UserActivity extends AppCompatActivity implements View.OnClickListener {
    Button bt_insert;
    EditText et_name,et_id,et_phone;
    MyopenHelper helper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user);
        et_name=(EditText)findViewById(R.id.et_name);
        et_id=(EditText)findViewById(R.id.et_id);
        et_phone=(EditText)findViewById(R.id.et_phone);
        bt_insert=(Button)findViewById(R.id.bt_insert);

        bt_insert.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bt_insert:
                String name=et_name.getText().toString();
                String id=et_id.getText().toString();
                String phone=et_phone.getText().toString();
                if ("".equals(name)) {
                    Toast.makeText(UserActivity.this, "姓名不能为空!", Toast.LENGTH_SHORT).show();
                }
                else if("".equals(id)){
                    Toast.makeText(UserActivity.this, "学号不能为空!", Toast.LENGTH_SHORT).show();
                }
                else if("".equals(phone)){
                    Toast.makeText(UserActivity.this, "电话不能为空!", Toast.LENGTH_SHORT).show();
                }
                else {
                    MyopenHelper helper = new MyopenHelper(this,"user.db",null,1);
                    SQLiteDatabase readableDatabase = helper.getReadableDatabase();
                    String sql = "select * from user where status = 1";
                    Cursor curor = readableDatabase.rawQuery(sql , null);
                    int count=0;
                    if(curor.moveToFirst()){
                        do{
                            count++;
                        }while(curor.moveToNext());
                    }
                    if(count==0){
                        sql = "insert into user (name,id,phone,status) values('" + name + "','" + id +  "','" + phone + "','" + "1" + "')";
                        helper = new MyopenHelper(this, "user.db", null, 1);
                        readableDatabase = helper.getReadableDatabase();
                        readableDatabase.execSQL(sql);
                        readableDatabase.close();
                        Toast.makeText(UserActivity.this, "注册成功!", Toast.LENGTH_SHORT).show();
                        Intent intent = new Intent(UserActivity.this, MainActivity.class);
                        finish();//结束当前活动
                        startActivity(intent);
                    }
                    else{
                        String name1="";
                        readableDatabase = helper.getReadableDatabase();
                        sql = "select * from user where name = '" + name + "'";
                        curor = readableDatabase.rawQuery(sql , null);
                        if(curor.moveToFirst()){
                            do{
                                name1 = curor.getString(curor.getColumnIndex("name"));
                            }while(curor.moveToNext());
                        }
                        if(name.equals(name1)){
                            Toast.makeText(UserActivity.this, "用户姓名已存在,请换一个用户姓名!", Toast.LENGTH_SHORT).show();
                            Intent intent = new Intent(UserActivity.this, UserActivity.class);
                            finish();//结束当前活动
                            startActivity(intent);
                        }
                        else {
                            sql = "insert into user (name,id,phone,status) values('" + name + "','" + id +  "','" + phone + "','" + "0" + "')";
                            helper = new MyopenHelper(this, "user.db", null, 1);
                            readableDatabase = helper.getReadableDatabase();
                            readableDatabase.execSQL(sql);
                            readableDatabase.close();
                            Toast.makeText(UserActivity.this, "注册成功!", Toast.LENGTH_SHORT).show();
                            Intent intent = new Intent(UserActivity.this, MainActivity.class);
                            finish();//结束当前活动
                            startActivity(intent);
                        }
                    }
                }
                break;
        }
    }
}

(9)UserBean

package com.example.tiwen2;

import java.io.Serializable;

public class UserBean implements Serializable{
    private String name;
    private String id;
    private String status;
    private String phone;

    public void setName(String name) {
        this.name=name;
    }

    public void setId(String id) {
        this.id=id;
    }

    public void setPhone(String phone) {
        this.phone=phone;
    }

    public void setStatus(String status) { this.status=status;}

    public String getName() {
        return name;
    }

    public String getStatus() {
        return status;
    }

    public String getPhone() {
        return phone;
    }
}

(10)WenBean

package com.example.tiwen2;

public class WenBean {
    private String name;
    private String time;
    private String space;
    private String wen;
    private String teshu;


    public void setName(String name) {
        this.name=name;
    }

    public void setTime(String time) {
        this.time=time;
    }

    public void setSpace(String space) {
        this.space=space;
    }

    public void setWen(String wen) {
        this.wen=wen;
    }

    public void setTeshu(String teshu) {
        this.teshu=teshu;
    }

    public String getName() {
        return name;
    }

    public String getTime() {
        return time;
    }

    public String getSpace() {
        return space;
    }

    public String getWen() {
        return wen;
    }

    public String getTeshu() {
        return teshu;
    }
}

(11)activity_main

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:rowCount="10"
    android:columnCount="1"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/bt_addtiwen"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="添加体温"
        android:textSize="26sp"
        android:layout_marginTop="0dp"/>

    <Button
        android:id="@+id/bt_showtiwen"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="浏览体温"
        android:textSize="26sp" />

    <Button
        android:id="@+id/bt_adduser"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="添加用户"
        android:textSize="26sp" />

    <Button
        android:id="@+id/bt_changeuser"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="切换用户"
        android:textSize="26sp" />

    <Button
        android:id="@+id/bt_tongji"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="今日添加体温统计"
        android:textSize="26sp" />

    <Button
        android:id="@+id/bt_new"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="生产14天EXCEL表"
        android:textSize="26sp" />

</GridLayout>

(12)activity_newexcel

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".NewExcelActivity">


</RelativeLayout>

(13)activity_show

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <ListView
        android:id="@+id/lv_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fastScrollEnabled="true" />

</LinearLayout>

(14)activity_tiwen

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:rowCount="10"
    android:columnCount="4"
    tools:ignore="NewApi"
    tools:context=".TiWenActivity"> <!--设置网格为10行4列-->

    <TextView
        android:id="@+id/tv_name0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="1、用户姓名:"
        android:textSize="20dip"  />

    <EditText
        android:id="@+id/tv_name"
        android:layout_width="230dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan="2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip" />

    <TextView
        android:id="@+id/tv_time0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="2、测量时间:"
        android:textSize="20dip"  />

    <EditText
        android:id="@+id/tv_time"
        android:layout_width="230dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip"  />

    <TextView
        android:id="@+id/tv_space0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="3、所在位置:"
        android:textSize="20dip"  />
    <EditText
        android:id="@+id/tv_space"
        android:layout_width="230dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip" />

    <TextView
        android:id="@+id/tv_wen"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="4、测量体温:"
        android:textSize="20dip"  />

    <EditText
        android:id="@+id/et_wen"
        android:layout_width="230dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="36.2"
        android:textSize="20dip" />

    <TextView
        android:id="@+id/tv_teshu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "4"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="5、特殊情况(可多选,如有其他需报告的情况请说明)"
        android:textSize="20dip" />

    <CheckBox
        android:id="@+id/cb_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "4"
        android:layout_marginLeft="4px"
        android:checked="true"
        android:gravity="left"
        android:text="无"
        android:textSize="20dip" />

    <CheckBox
        android:id="@+id/cb_2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "4"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="2020年12月27日至今去过或现在居住在中高风险地区"
        android:textSize="20dip" />

    <EditText
        android:id="@+id/et_2"
        android:layout_width="400dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan="4"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="2、"
        android:textSize="20dip"
        android:visibility="gone"/>

    <CheckBox
        android:id="@+id/cb_3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "4"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="本人或家人正在集中隔离"
        android:textSize="20dip" />

    <EditText
        android:id="@+id/et_3"
        android:layout_width="400dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan="4"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="3、"
        android:textSize="20dip"
        android:visibility="gone"/>

    <CheckBox
        android:id="@+id/cb_4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "4"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="今日居住地异动请说明情况"
        android:textSize="20dip" />

    <EditText
        android:id="@+id/et_4"
        android:layout_width="400dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan="4"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="4、"
        android:textSize="20dip"
        android:visibility="gone"/>

    <CheckBox
        android:id="@+id/cb_5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "4"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="其他情况"
        android:textSize="20dip" />

    <EditText
        android:id="@+id/et_5"
        android:layout_width="400dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan="4"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="5、"
        android:textSize="20dip"
        android:visibility="gone"/>

    <Button
        android:id="@+id/bt_insert"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_columnSpan="4"
        android:text="提交"
        android:textSize="20dip" />

</GridLayout>

(15)activity_tongji

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:rowCount="10"
    android:columnCount="4"
    tools:ignore="NewApi"
    tools:context=".TongJiActivity"> <!--设置网格为10行4列-->

    <TextView
        android:id="@+id/text1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "4"
        android:text="体温上报统计"
        android:textSize="30dp"
        android:textStyle="bold"
        android:gravity="center" />

    <TextView
        android:id="@+id/tv_renshu0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="1、总人数:"
        android:textSize="20dip"  />

    <TextView
        android:id="@+id/tv_renshu"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan="2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip" />

    <TextView
        android:id="@+id/tv_renshu01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="2、登记人数:"
        android:textSize="20dip"  />

    <TextView
        android:id="@+id/tv_renshu1"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan="2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip" />

    <TextView
        android:id="@+id/tv_renshu02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="3、未登记人数:"
        android:textSize="20dip"  />

    <TextView
        android:id="@+id/tv_renshu2"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan="2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip" />

    <TextView
        android:id="@+id/tv_zheng0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="4、正常人数:"
        android:textSize="20dip"  />

    <TextView
        android:id="@+id/tv_zheng"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip"  />

    <TextView
        android:id="@+id/tv_yi0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="5、疑似人数:"
        android:textSize="20dip"  />
    <TextView
        android:id="@+id/tv_yi"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip" />

    <TextView
        android:id="@+id/tv_chang0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="6、异常人数:"
        android:textSize="20dip"  />

    <TextView
        android:id="@+id/tv_chang"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip" />

</GridLayout>

(16)activity_user

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:rowCount="10"
    android:columnCount="4"
    tools:ignore="NewApi"
    tools:context=".UserActivity"> <!--设置网格为10行4列-->

    <TextView
        android:id="@+id/tv_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="用户姓名:"
        android:textSize="20dip"  />

    <EditText
        android:id="@+id/et_name"
        android:layout_width="260dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan="2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip" />

    <TextView
        android:id="@+id/tv_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="用户学号:"
        android:textSize="20dip"  />

    <EditText
        android:id="@+id/et_id"
        android:layout_width="260dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip"  />

    <TextView
        android:id="@+id/tv_phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text="用户电话:"
        android:textSize="20dip"  />

    <EditText
        android:id="@+id/et_phone"
        android:layout_width="260dp"
        android:layout_height="wrap_content"
        android:layout_columnSpan = "2"
        android:layout_marginLeft="4px"
        android:gravity="left"
        android:text=""
        android:textSize="20dip" />

    <Button
        android:id="@+id/bt_insert"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_columnSpan="4"
        android:text="注册"
        android:textSize="20dip" />

</GridLayout>

(17)content_tiwen

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/tv_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </TextView>

    <TextView
        android:id="@+id/tv_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </TextView>

    <TextView
        android:id="@+id/tv_space"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </TextView>

    <TextView
        android:id="@+id/tv_wen"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </TextView>

    <TextView
        android:id="@+id/tv_teshu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </TextView>

</LinearLayout>

(18)content_user

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/tv_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </TextView>

    <Button
        android:id="@+id/bt_change"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="切换用户"
        android:visibility="gone">
    </Button>

</LinearLayout>

 

原文地址:https://www.cnblogs.com/Clark-Shao/p/14902087.html