设为首页 加入收藏

TOP

Android 实现省份城市的选择,并获取城市编号
2014-11-24 03:14:27 来源: 作者: 【 】 浏览:1
Tags:Android 实现 省份 城市 选择 获取 编号

该程序主要使用 中央气象局 省份 城市数据库为基础 进行读取


城市数据库下载


具体下载目录在 /2013年资料/7月/7日/Android 实现省份城市的选择,并获取城市编号


本文源码下载


下载在Linux公社的1号FTP服务器里,下载地址:


用户名:www.6688.cc


在 2013年LinuxIDC.com\7月\Android 实现省份城市的选择,并获取城市编号


下载方法见 http://www.linuxidc.net/thread-1187-1-1.html


-------------------------------------分割线-------------------------------------


下载的数据库 db_weather.db 放到sdcard/weather 目录下面 方便后续操作


为了更好的了解数据库,使用 SQLite Database Browser 可以打开数据库 查看数据 和表等信息,如下





了解了表的构成可以实现操作了


androidManifest.xml


配置文件声明 添加操作sdcard 权限


< xml version="1.0" encoding="utf-8" >
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 分别实现城市 省份的选择


< xml version="1.0" encoding="utf-8" >
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"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>



】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇iOS 从相机或相册获取图片并裁剪 下一篇Android简单的获取不同城市实时天..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Python中文网 - 人生 (2025-12-24 18:49:47)
·【整整648集】这绝对 (2025-12-24 18:49:44)
·Python超详细一条龙 (2025-12-24 18:49:42)
·【超详细】JDK 下载 (2025-12-24 18:19:32)
·Java_百度百科 (2025-12-24 18:19:29)