该程序主要使用 中央气象局 省份 城市数据库为基础 进行读取
下载的数据库 db_weather.db 放到sdcard/weather 目录下面 方便后续操作
为了更好的了解数据库,使用 SQLite Database Browser 可以打开数据库 查看数据 和表等信息,如下
了解了表的构成可以实现操作了
androidManifest.xml
配置文件声明 添加操作sdcard 权限
package="com.cityselection"
android:versionCode="1"
android:versionName="1.0">
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
android:name=".City_SelectionActivity"
android:label="@string/app_name">
package="com.cityselection"
android:versionCode="1"
android:versionName="1.0" >
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
android:name=".City_SelectionActivity"
android:label="@string/app_name" >
布局文件main.xml
主要使用两个 spinner 分别实现城市 省份的选择
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
android:text="省份/直辖市"
android:textSize="20dp"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
android:id="@+id/provinces"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
android:text="市/县"
android:textSize="20dp"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
android:id="@+id/city"
andro