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



    }
  • 相关阅读:
    XP的定时关机命令?
    Vim简明教程【CoolShell】
    我和小美的撸码日记(3)之中的一个句话搞定MVC表单页数据绑定与提交
    Linux/RedHat 编译安装GNU gcc 4.9.0 (g++)
    真实股市房市信托本质,金融故事三则:钱都去哪儿了?
    一分钟制作U盘版BT3
    Android Studio中导入第三方库
    WebService究竟是什么?
    “权限”用英语该用哪个?
    Cocos2d-x v3.0 新的事件调度方法 lambda表达式的使用
  • 原文地址:https://www.cnblogs.com/D10304/p/14910391.html
Copyright © 2011-2022 走看看