zoukankan      html  css  js  c++  java
  • 体温上报APP——查看记录

    查看体温功能可以查看自己所填信息的情况

    ShowActivity.java文件:

     1 package com.example.application;
     2 
     3 import android.content.Intent;
     4 import android.database.Cursor;
     5 import android.database.sqlite.SQLiteDatabase;
     6 import android.os.Bundle;
     7 import android.view.View;
     8 import android.widget.Button;
     9 import android.widget.TextView;
    10 
    11 import androidx.annotation.Nullable;
    12 import androidx.appcompat.app.AppCompatActivity;
    13 
    14 import static com.example.application.Constants.TABLE_NAME;
    15 
    16 public class ShowActivity extends AppCompatActivity implements View.OnClickListener{
    17     private Button btShowzzt;
    18     private Button btShowout;
    19     private DatabaseHelper myHelper;
    20     public SQLiteDatabase db;
    21     private String username;
    22     String str="";
    23 
    24     protected void onCreate(@Nullable Bundle savedInstanceState) {
    25         Intent intent=getIntent();
    26         username=intent.getStringExtra("user_name");
    27         super.onCreate(savedInstanceState);
    28         setContentView(R.layout.activity_show);
    29         btShowzzt=(Button)findViewById(R.id.bt_show_zzt);
    30         btShowout=(Button)findViewById(R.id.bt_show_out);
    31         btShowzzt.setOnClickListener(this);
    32         btShowout.setOnClickListener(this);
    33         final TextView tv=(TextView)findViewById(R.id.allshow);
    34         myHelper=new DatabaseHelper(this);
    35         SQLiteDatabase db=myHelper.getWritableDatabase();
    36         Cursor cursor = db.query(TABLE_NAME, null, "name like ?", new String[]{username}, null, null, null);//读取数据库所有信息
    37         if(cursor.moveToFirst()){
    38             do{
    39                 String name=cursor.getString(cursor.getColumnIndex("name"));
    40                 String date=cursor.getString(cursor.getColumnIndex("date"));
    41                 String time=cursor.getString(cursor.getColumnIndex("time"));
    42                 String location=cursor.getString(cursor.getColumnIndex("location"));
    43                 String temperature=cursor.getString(cursor.getColumnIndex("temperature"));
    44                 String situation=cursor.getString(cursor.getColumnIndex("situation"));
    45                 String tip=cursor.getString(cursor.getColumnIndex("tip"));
    46                 str+=name+"		"+ date+"		"+location+"		"+temperature+"		"+situation+"		"+tip+"
    ";//将数据库信息存到str中并换行
    47             }while (cursor.moveToNext());
    48         }
    49         cursor.close();
    50         tv.setText(str);//打印信息
    51     }
    52 
    53     @Override
    54     public void onClick(View v) {
    55         switch (v.getId()){
    56             case R.id.bt_show_zzt:
    57                 Intent intent = new Intent(this, PersonActivity.class);
    58                 intent.putExtra("user_name",username);
    59                 startActivity(intent);
    60                 break;
    61             case R.id.bt_show_out:
    62                 Intent intent2 = new Intent(this, OutActivity.class);
    63                 intent2.putExtra("user_name",username);
    64                 startActivity(intent2);
    65                 break;
    66         }
    67     }
    68 
    69 }

    activity_show.xml文件:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:orientation="vertical"
     4     android:layout_width="match_parent"
     5     android:layout_height="match_parent"
     6     android:background="@mipmap/bj3"
     7     >
     8     <LinearLayout
     9         android:layout_width="match_parent"
    10         android:layout_height="match_parent"
    11         android:orientation="vertical"
    12         >
    13         <TextView
    14             android:layout_width="wrap_content"
    15             android:layout_height="wrap_content"
    16             android:textSize="20sp"
    17             android:text="姓名    时间    位置    体温     情况     备注"/>
    18         <TextView
    19             android:id="@+id/allshow"
    20             android:layout_width="match_parent"
    21             android:layout_height="wrap_content"
    22             android:layout_marginTop="25dp"
    23             android:textSize="15sp" />
    24         <LinearLayout
    25             android:layout_width="wrap_content"
    26             android:layout_height="wrap_content"
    27             android:layout_marginTop="25dp"
    28             android:layout_gravity="center"
    29             android:orientation="horizontal">
    30             <Button
    31                 android:id="@+id/bt_show_zzt"
    32                 android:layout_width="wrap_content"
    33                 android:layout_height="wrap_content"
    34                 android:text="柱状图"
    35                 android:layout_weight="1"
    36                 android:textColor="#F2F2F2"
    37                 android:background="#328359"
    38 
    39                 android:layout_marginRight="20dp"
    40                 />
    41 
    42             <Button
    43                 android:id="@+id/bt_show_out"
    44                 android:layout_width="wrap_content"
    45                 android:layout_height="wrap_content"
    46                 android:text="打印"
    47                 android:layout_weight="1"
    48                 android:textColor="#F2F2F2"
    49                 android:background="#328359"
    50                 android:layout_marginLeft="20dp"
    51                 />
    52         </LinearLayout>
    53 
    54     </LinearLayout>
    55 
    56 
    57 </ScrollView>

    查看记录界面截图:

     打印功能可以导出到EXCEL表中,下一篇博客展示

  • 相关阅读:
    MySQL三种备份
    四层和七层负载均衡的区别
    触发器及触发器的作用
    sql 存储过程
    自动ftp 上传
    #题目:有10 台被监控主机、一台监控机,在监控机上编写脚本,一旦某台被监控机器/ 分区适用率大于80%, 就发邮件报警放到crontab 里面, 每10 分钟检查一次
    /proc/sys 子目录的作用
    Linking code for an enhanced application binary interface (ABI) with decode time instruction optimization
    facebook webdriver 学习
    WebDriverException: Message: A session is either terminated or not started
  • 原文地址:https://www.cnblogs.com/znjy/p/14905801.html
Copyright © 2011-2022 走看看