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



    }
  • 相关阅读:
    工作生活中需要知道的常识名词
    ICON的设计很重要
    100offer 为专业程序打造的招聘平台
    2014年工作生活大总结
    游戏模块分析总结(3)之引导篇
    游戏模块分析总结(2)之UI、操作篇
    数字证书及CA介绍
    Hyperledger Fabric密码模块系列之BCCSP(五)
    GDB十分钟教程
    Hyperledger Fabric密码模块系列之BCCSP(四)
  • 原文地址:https://www.cnblogs.com/D10304/p/14910391.html
Copyright © 2011-2022 走看看