您的位置:首页 > 移动开发 > Android开发

Android学习之天气预报简单版

2015-06-27 17:16 555 查看
自己想做一个简单的天气预报,由于能力有限,暂时做个简单的。

大概讲一下自己的开发步骤吧。

第一步:获得可以开发的json数据的及时更新的接口。

通过强大的度娘,我这里使用的json的地址是:http://wthrcdn.etouch.cn/weather_mini?citykey=101010100

第二步:实现各大城市编号的获取

实现方法:网上下载一个包含各大城市的db文件db_weather.db,下载地址:http://pan.baidu.com/s/1hqkxlxM

这个db文件里面包含中国各大省份及城市编号,里面的大概内容截图如下所示

这个是省份表:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/tvCity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="28sp"/>

<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#FF0000ff"/>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tvWendu"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="25sp"/>
<TextView
android:id="@+id/tvWenduValue"
android:layout_weight="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="25sp"/>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#FFff0099"/>

<TextView
android:id="@+id/tvCurrentWendu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="25sp"/>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#FFff9999"/>

<TextView
android:id="@+id/tvNote"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="25sp"/>

<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#FF00ff99"/>

<TextView
android:id="@+id/tvCurrentCity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="25sp"/>

<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#FF001155"/>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tvTomWendu"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="25sp"/>
<TextView
android:id="@+id/tvTomWenduValue"
android:layout_weight="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="25sp"/>
</LinearLayout>

<View
android:layout_width="fill_parent"
android:layout_height="0.5dip"
android:background="#FF001100"/>

<TextView
android:id="@+id/tvTodayType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="25sp"/>

<View
android:layout_width="fill_parent"
android:layout_height="0.5dip"
android:background="#FF008800"/>

<TextView
android:id="@+id/tvTomorrowType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="25sp"/>
</LinearLayout>


View Code
到此,这个简单的天气程序基本上结束了。

整个项目需要下载,在此给出项目下载地址:http://pan.baidu.com/s/1gd3wcqJ

有什么问题尽管提出
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: