个人作业阶段一 3

今天完成填报数据的展示

1、在activity_show_xml中添加textview控件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    tools:context=".ShowActivity2"
    android:orientation="horizontal"
    android:background="@drawable/bk4">

<TextView
    android:id="@+id/SHOW"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
    
</RelativeLayout>

  

2、ShowActivity.java

package com.example.myapplication;

import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import org.litepal.LitePal;

import java.util.List;

import static com.example.myapplication.RegisterActivity.username;

public class ShowActivity2 extends AppCompatActivity {

    private TextView SHOW;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show2);

        SHOW = findViewById(R.id.SHOW);
        SHOW.setMovementMethod(ScrollingMovementMethod.getInstance());
        String showname2=username;

        String s;
        StringBuffer sb = new StringBuffer(256);
        List<Infomation> infomations = (List<Infomation>) LitePal.where("zhu_name=?",showname2).find(Infomation.class);
        List<User> users = (List<User>) LitePal.where("user_name=?",showname2).find(User.class);
            for(Infomation infomation:infomations) {
                    sb.append("姓名:" +infomation.getZhu_name()+"\t"+"学号:"/*+user.getUser_xuehao()+"\t"+"班级:"+user.getUser_class()+"\t"*/
                            + "日期:"+infomation.getZhu_date()+"\t"+"时间:"+infomation.getZhu_time()+"\t"
                            + "体温:"+infomation.getZhu_tiwen()+"\t"+"地址:"+infomation.getZhu_add()+"\t"+"说明:"+infomation.getZhu_shuoming()+"\n");
                }

            s=sb.toString().trim();
            SHOW.setText(s);
    }
}

  

这里只是简单的把数据进行了打印,并没有采用比较美观的方法。

今后将继续完善补充

 

posted @ 2021-03-05 13:28  第厘  阅读(29)  评论(0编辑  收藏  举报