• 个人作业阶段一 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()+"	"+"学号:"/*+user.getUser_xuehao()+"	"+"班级:"+user.getUser_class()+"	"*/
                                + "日期:"+infomation.getZhu_date()+"	"+"时间:"+infomation.getZhu_time()+"	"
                                + "体温:"+infomation.getZhu_tiwen()+"	"+"地址:"+infomation.getZhu_add()+"	"+"说明:"+infomation.getZhu_shuoming()+"
    ");
                    }
    
                s=sb.toString().trim();
                SHOW.setText(s);
        }
    }
    

      

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

    今后将继续完善补充

  • 相关阅读:
    每天一个linux命令(40):wc命令
    每天一个linux命令(39):grep 命令
    每天一个linux命令(38):cal 命令
    每天一个linux命令(37):date命令
    每天一个linux命令(36):diff 命令
    每天一个linux命令(35):ln 命令
    [android] Activity 的生命周期 以及横屏竖屏切换时 Activity 的状态变化
    Android onConfigurationChanged 不执行
    faster-rcnn anchor 介绍
    Faster-rcnn centos tensorflow
  • 原文地址:https://www.cnblogs.com/ltw222/p/14912724.html
Copyright © 2020-2023  润新知