Android 基于百度定位sdk ,获取城市,使用json解析天气

关于百度定位sdk的使用 参考官方文档 https://lbsyun.baidu.com/index.php?title=android-locsdk

JSON 解析 参考了 https://blog.youkuaiyun.com/double2hao/article/details/68482900 

使用的 天气接口 http://wthrcdn.etouch.cn/weather_mini?city=北京

demo下载:https://download.youkuaiyun.com/download/weixin_42447313/10483975

实现后的效果


布局代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.yazz.yaweather.MainActivity">

    <TextView
        android:id="@+id/location_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textSize="16dp" />

    <EditText
        android:id="@+id/et1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/location_view"
        android:hint="请输入城市名称:" />

    <RelativeLayout
        android:id="@+id/rl1"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_below="@id/et1"
        android:layout_marginTop="20dp">

        <TextView
            android:id="@+id/weather_view"
            android:layout_width="192dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:textSize="16dp" />

        <ImageView
            android:id="@+id/iv1"
            
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值