zoukankan      html  css  js  c++  java
  • 体温填报APP--主界面设计

    主界面包括上述的功能选项

    同时向用户提示你的当前用户信息

    package com.example.tiwen20;

    import androidx.appcompat.app.AppCompatActivity;
    import android.content.Intent;
    import android.os.Build;
    import android.os.Bundle;
    import android.os.Handler;
    import android.os.StrictMode;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;

    public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private Button shangbao_bt;
    private Button qiehuan_bt;
    private Button zhuce_bt;
    private Button quanbutiwen_bt;
    private Button shengchengbiao_bt;
    private Button tongji_bt;
    private Button MPandroid_bt,Map_bt,Map_bt1;
    private Intent i,m,n,o,k,x,y,q,p;
    private String name,classes;
    private String str_location;
    private Handler handler_location = new Handler();
    private Toast toast;
    private List<TiwenBean> list;
    private TiwenDB tiwenDB;
    private List<TiwenBean> listMPandroid;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState) ;
    setContentView(R.layout.activity_main);
    initTiwen();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
    StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
    StrictMode.setVmPolicy( builder.build() );
    }
    }


    private void initTiwen() {
    shangbao_bt = (Button) this.findViewById(R.id.bt_shangbao);
    qiehuan_bt = (Button) this.findViewById(R.id.bt_qiehuan);
    zhuce_bt = (Button) this.findViewById(R.id.bt_zhuce);
    quanbutiwen_bt = (Button) this.findViewById(R.id.bt_quanbutiwen);
    shengchengbiao_bt = (Button) this.findViewById(R.id.bt_shengchengbiao);
    tongji_bt = (Button) this.findViewById(R.id.bt_tongji);
    MPandroid_bt = (Button) this.findViewById(R.id.bt_MPandroid);
    Map_bt = (Button)this.findViewById(R.id.bt_Map);
    Map_bt1 = (Button)this.findViewById(R.id.bt_Map1);
    zhuce_bt.setOnClickListener(this);
    shangbao_bt.setOnClickListener(this);
    qiehuan_bt.setOnClickListener(this);
    quanbutiwen_bt.setOnClickListener(this);
    shengchengbiao_bt.setOnClickListener(this);
    tongji_bt.setOnClickListener(this);
    MPandroid_bt.setOnClickListener(this);
    Map_bt.setOnClickListener(this);
    Map_bt1.setOnClickListener(this);

    }

    public String getTime(){
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
    Date curDate = new Date();
    String str = format.format(curDate);
    return str;
    }
    @Override
    public void onClick(View v) {
    switch (v.getId()) {
    case R.id.bt_shangbao:
    i = new Intent(this, addActivity.class);
    i.putExtra("time",getTime());
    i.putExtra("name",name);
    LocationUtil locationUtil = new LocationUtil();
    locationUtil.initLocation(getApplicationContext());
    new Thread(new Runnable() {
    @Override
    public void run() {
    try {
    str_location= LocationUtil.getAddress(LocationUtil.location,getApplicationContext());
    //位置信息-----一个字符串
    }catch (IOException e){
    e.printStackTrace();
    }
    final String finalStr_location = str_location;
    handler_location.post(new Runnable() {
    @Override
    public void run() {
    //Toast.makeText(getApplicationContext(), finalStr_location,Toast.LENGTH_LONG).show();
    }
    });
    }
    }).start();
    i.putExtra("didian",str_location);
    startActivity(i);
    break;
    case R.id.bt_zhuce:
    m = new Intent(this, zhuceActivity.class);
    startActivity(m);
    break;
    case R.id.bt_qiehuan:
    k = new Intent(this,qiehuanActivity.class);
    startActivity(k);
    break;
    case R.id.bt_quanbutiwen:
    n = new Intent(this, alltiwenActivity.class);
    startActivity(n);
    break;
    case R.id.bt_shengchengbiao:
    x = new Intent(this,shengchengbiaoActivity.class);
    x.putExtra("name",name);
    startActivity(x);
    break;
    case R.id.bt_tongji:
    o = new Intent(this,tongjiActivity.class);
    o.putExtra("time",getTime());
    o.putExtra("classes",classes);
    startActivity(o);
    break;
    case R.id.bt_MPandroid:
    y = new Intent(this,MPandroidActivity.class);
    y.putExtra("name",name);
    startActivity(y);
    break;
    case R.id.bt_Map:
    q = new Intent(this,MapActivity.class);
    q.putExtra("time",getTime());
    q.putExtra("classes",classes);
    startActivity(q);
    break;
    case R.id.bt_Map1:
    p = new Intent(this,Map1Activity.class);
    startActivity(p);
    break;
    default:
    break;
    }
    }

    @Override
    protected void onResume() {
    super.onResume();
    Intent i = getIntent();
    classes = i.getStringExtra("classes");
    name =i.getStringExtra("name");
    if(name != null && name.length() != 0){
    toast = new Toast(this);
    toast.makeText(MainActivity.this,"当前用户为:"+classes+""+name,Toast.LENGTH_LONG).show();
    }
    }
    }
  • 相关阅读:
    086 01 Android 零基础入门 02 Java面向对象 01 Java面向对象基础 03 面向对象基础总结 01 面向对象基础(类和对象)总结
    085 01 Android 零基础入门 02 Java面向对象 01 Java面向对象基础 02 构造方法介绍 04 构造方法调用
    jQuery UI组件库Kendo UI使用技巧小分享
    Kendo UI ListView模板功能,让Web开发更轻松
    UI组件套包DevExpress ASP.NET Core v20.2新版亮点:全新的查询生成器
    Devexpress WinForms最新版开发.NET环境配置Visual Studo和SQL Server对应版本
    全新的桌面应用数据可视化呈现方式,Sankey Diagram控件你了解多少?
    java中的递归方法
    连接数据库查询 将查询结果写入exce文件中
    java连接mysql数据查询数据
  • 原文地址:https://www.cnblogs.com/huangmouren233/p/14912895.html
Copyright © 2011-2022 走看看