zoukankan      html  css  js  c++  java
  • 体温上报软件开发

    这里是三个功能,获取地址,自动显示姓名,自动显示时间

    //---------------------------------------------------------------------自动读取姓名

    TextName=findViewById(R.id.TextName);
    showName();
    //---------------------------------------------------------------------获取当前地址
    button_address = (Button) findViewById(R.id.buttonGetAdd);
    button_address.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {

    if (button_address.getText().equals("获取地址")) {
    button_address.setText("stop");
    //声明AMapLocationClient类对象
    //初始化定位
    mLocationClient = new AMapLocationClient(getApplicationContext());

    //启动定位
    mLocationClient.startLocation();
    mLocationListener = new AMapLocationListener() {


    @Override
    public void onLocationChanged(AMapLocation location) {
    if (location != null) {
    if (location.getErrorCode() == 0) {
    //解析定位结果
    String result=getAddress(location);
    ed_address = findViewById(R.id.editAddress);
    ed_address.setText(result);
    }

    }
    }
    };
    //设置定位回调监听
    mLocationClient.setLocationListener(mLocationListener);

    //异步获取定位结果
    initLocation();

    } else if (button_address.getText().equals("stop")) {
    button_address.setText("获取地址");
    close();

    }
    }
    });

    //-------------------------------------------------------------------------自动显示时间
    Calendar calendar = Calendar.getInstance();
    //年
    int year = calendar.get(Calendar.YEAR);
    //月
    int month = calendar.get(Calendar.MONTH)+1;
    //日
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    //获取系统时间
    //小时
    int hour = calendar.get(Calendar.HOUR_OF_DAY);
    //分钟
    int minute = calendar.get(Calendar.MINUTE);
    //秒

    tv_time = findViewById(R.id.tv_time);
    if(minute<10)
    {tv_time.setText(year+"年"+month+"月"+day+"日"+hour+":"+"0"+minute);}
    else {tv_time.setText(year+"年"+month+"月"+day+"日"+hour+":"+minute);}



    }
  • 相关阅读:
    Django模板语言进阶
    ORM基础之ORM介绍和基础操作
    ORM关于表那些事
    ORM之基础操作进阶
    ORM基础之字段及其参数介绍
    AJAX初识(原生JS版AJAX和Jquery版AJAX)
    AJAX异步、sweetalert、Cookie和Session初识
    在一个千万级的数据库查寻中,如何提高查询效率?
    A fatal error has been detected by the Java Runtime Environment(jdk 1.6的一个BUG)
    外网映射工具地址
  • 原文地址:https://www.cnblogs.com/D10304/p/14910391.html
Copyright © 2011-2022 走看看