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();
    }
    }
    }
  • 相关阅读:
    Linux的用户和组的属性
    Linux文件/目录 的新建、复制、移动(更名)、删除、查看、压缩命令
    排序算法和实现
    面试-三三原则
    phpstudy 最新版linux 面板 web防火墙后门防护功能教程
    小白必看的Python爬虫流程
    Python3迭代器与生成器
    python的异常处理机制
    python变量的作用域
    值得收藏的Python第三方库
  • 原文地址:https://www.cnblogs.com/huangmouren233/p/14912895.html
Copyright © 2011-2022 走看看