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);}



    }
  • 相关阅读:
    软件测试人员的年终绩效考核怎么应对
    收藏
    顶踩组件 前后两版
    订阅组件
    hdu 1963 Investment 完全背包
    hdu 4939 Stupid Tower Defense 动态规划
    hdu 4405 Aeroplane chess 动态规划
    cf 414B Mashmokh and ACM 动态规划
    BUPT 202 Chocolate Machine 动态规划
    hdu 3853 LOOPS 动态规划
  • 原文地址:https://www.cnblogs.com/D10304/p/14910391.html
Copyright © 2011-2022 走看看