Android 中文天气预报程序
基于android系统的天气预报查询系统大学论文

河北农业大学本科毕业论文(设计)题目:基于android系统的天气预报查询系统摘要近几年来随着3G技术成熟和智能手机的不断普及,移动应用的需求与日俱增,移动应用开发成为当下最热门的技术之一。
在Google和Android手机联盟的共同推动下,Android在众多移动应用开发平台中脱颖而出。
Android是一个真正意义上的开源智能手机操作系统,该系统一经推出立即受到全球移动设备厂商和开发者的热捧,手机已被赋予了除通话以外的其它许多功能。
全新的手机软件领域已逐渐聚焦了众多软件开发商的目光,软件开发者和软件用户将共同面临这个振奋人心的新境界。
本设计使用Android设计技术开发了一种运用在Android系统上的手机天气预报软件系统,本系统通过选择城市来获得天气,风向,温度等信息。
基于android的天气预报系统软件可以使用户对于各地的天气情况的实时掌握,极大的方便了用户的出行和行程安排,避免了不必要的麻烦,具有很强的实用性。
关键词:天气预报系统;android开发AbstractIn recent years, with the 3G technology matures and the growing popularity of smart phones, the increasing demand for mobile applications, mobile application development become the most popular technology. Given a friendly boost by Google and Android Handset Alliance, Android stands out in numerous mobile application development platforms. Android is a truly open-source smart phone operating system, which once launched immediately by the global mobile device manufacturers and developers blitz, mobile phones have been given in addition to many other functions outside the phone. The new phone software field has gradually focused the attention of a large number of software developers, software developers and software users will be facing this exciting new realm.This design uses design techniques developed an Android application in the Android system mobile weather software system, the system by selecting the city to get weather, wind direction, temperature and other information. Android based software allows users to weather forecasting system for real-time weather conditions around the master, a great convenience to the user's travel and travel arrangements, to avoid unnecessary trouble, and highly practical.Keywords: Weather forecast system; android development目录1. 需求分析 (1)1.1开发背景 (1)1.2系统研究内容 (1)1.3项目需求分析 (1)2. GOOGLE ANDROID移动平台的相关理论 (1)2.1G OOGLE ANDROID 移动平台的概述 (1)2.1.1 Android系统的特点 (2)2.1.2 Android的功能 (2)2.2G OOGLE ANDROID移动平台开发过程研究 (2)2.3G OOGLE ANDROID移动平台下的应用研究 (3)2.4小结 (3)3. 项目设计 (4)3.1项目总体设计 (4)3.2系统功能界面 (4)3.2.1 欢迎界面 (4)3.2.2 设置所在城市界面 (5)3.2.3 天气显示界面 (6)3.2.4 Widget桌面小部件界面 (7)3.3设计目标 (8)4. 系统设计 (8)4.1开发及运行环境 (8)4.2数据库设计 (8)4.3主要方法及步骤 (8)4.4主要方法及技术 (9)5. 主要模块 (9)5.1项目框架 (9)5.2主要功能实现 (10)5.2.1 导入db_weather.db数据库文件 (10)5.2.2 实现城市列表的创建与过滤 (11)5.2.3 访问网络得到天气信息 (14)5.2.4 Widget窗体小部件的更新 (15)6. 功能测试 (17)结论 (21)参考文献 (22)基于android系统的天气预报查询系统1. 需求分析1.1 开发背景近几年来随着3G技术成熟和智能手机的不断普及,移动应用的需求与日俱增,移动应用开发成为当下最热门的技术之一。
基于Android平台的天气预报系统的设计与开发毕业论文

基于Android平台的天气预报系统的设计与开发摘要:安卓是谷歌于2008年推出的一个智能手机操作系统,其独特的设计模式使得开发手机软件变得非常简单。
该论文介绍了一款安卓天气预报的设计与实现过程。
用户可以通过主界面选择城市来获得包括风力、风向、紫外线强度等的天气信息。
基于手机的天气预报系统能够使用户对于各地的天气情况实时掌握,方便用户的出行和行程安排,具有一定的实用性。
关键字:实时预报,Android,温度检测,定位The Design and Development of Weather Forecast System based on the Android SystemAbstract: Android is a Smartphone system launched by Google in 2008, whose unique design pattern makes it easier to develop mobile phone softwares . The paper introduces the process of the design and implementation of a Android weather forecast system. Users can choose a city what he likes from the home screen to get access to the weather information ,including wind,wind direction,strong of ultraviolet light and so on.Weather forecast system based on mobile phone enables users to take the real-time control of weather conditions of all parts,thus bringing great convenience to the user's travel and travel arrangements, and has a certain practicality Keywords: real-time forecast, Android , Temperature detection , locationⅠ毕业论文(设计)原创性声明本人所呈交的毕业论文(设计)是我在导师的指导下进行的研究工作及取得的研究成果。
基于Android平台的天气预报系统设计与实现

a n d r o i d : v a l u e = ” 请输人您 的用 户 Ke y ” / > 注意 ,上 面这个 a n d r o i d : n a me的值不 是填 包名 ,笔
者开始 误 以为是填包名 ,填上 了包名 在后 面 的程 序运行
过程 中就发 生 了 I N V AL I D US E R KE Y错误 。
“ l i b s ”文 件夹 ,将定位包拷 贝到 l i b s 的根 目录下 。
r eque s t We at he r UPda t e s ( i nt w ea t h e r TyP e ,
1 . 4 定 位程序设计 与实现
1 . 4 . 1 注 册 监 听
1 . 3 在项 目中配置权 限及 k e y
通过 a Ma p L o c a t i o n . g e t A Ma p L o c E x c e p t i o n ( ) 方 法 获
用 名称 ,绑定服 务 ,拷 贝 S H A1 值 ,然后 输入包 名 ,点 取定 位异 常对 象 ,再通 过异 常对 象返 回的错误码 判断是
软件开 发与应 用
C h i n a C o m - p ● , u , t _ e - r — & Ⅱ - C t o - _ m m u n i c a t i o n
2 0 1 5 年 第l 9 期
拿到 S HAI 值 以后 ,在 高德地 图的控制 台 中输 入应
击 获取 KE Y,就可 以得 到 K E Y值 。
AMa p L o c a l We a t h e r L i s t e n e r l i s t e n e r ) 方 法 发 送 天 气
基于Android平台的天气预报系统设计

基于Android平台的天气预报系统设计基于Android平台的天气预报系统设计天气预报是人们日常生活中不可或缺的信息之一,无论是为了出行还是安排活动,对天气情况的了解都有着重大的意义。
为了满足用户对天气预报的需求,本文将基于Android平台设计一款天气预报系统。
一、系统需求分析1. 用户需求用户对天气预报系统的主要需求包括实时天气信息、七天内的天气预报、城市切换等功能,并能够提供准确、可靠的天气数据。
2. 数据需求系统需要从可靠的天气数据源获取相关天气数据,包括温度、湿度、风力、风向等信息,并需要支持多个城市的数据查询。
3. 功能需求系统需要提供以下功能:(1)实时天气信息展示:根据用户选择的城市,显示当前城市的实时天气信息,包括温度、湿度、天气状况等。
(2)天气预报:显示未来七天内的天气预报,包括每天的温度范围、天气状况等。
(3)城市切换:支持用户根据需求切换城市,以获取不同城市的天气预报。
(4)数据更新:系统需要能够自动定时更新天气数据,以保持数据的准确性。
二、系统设计1. 界面设计系统的主要界面包括实时天气信息展示界面和天气预报界面。
实时天气信息展示界面会显示当前城市的温度、湿度、天气状况等信息,以及一张相关的天气图片。
天气预报界面会显示未来七天内的天气情况,包括每天的温度范围、天气状况等。
2. 数据获取与处理系统需要通过网络请求从可靠的天气数据源获取相关天气数据。
获取到的数据可以通过JSON格式进行解析,并存储到系统数据库中,以便后续的展示和查询。
3. 功能实现(1)实时天气信息展示:系统会在主界面上显示当前城市的实时天气信息。
通过定时请求服务器接口,获取最新的天气数据,并更新到界面上。
(2)天气预报:在天气预报界面中,系统会显示未来七天内的天气预报。
利用已储存的数据,将七天内的天气数据一一展示出来,包括日期、温度范围、天气状况等。
(3)城市切换:用户可以通过系统提供的城市切换功能,选择不同的城市。
Android天气预报系统文档

[键入公司名称]实训课程设计天气预报程序xx2011/12/291项目任务概述1.1项目背景随着3G时代的到来,移动互联网成为Internet下一个热点,android可以很好的使用Internet,获取网站上的数据,android天气预报系统就利用这一方式为用户提供服务。
天气预报的主要功能是为用户提供今日以及未来两天的天气预报。
1.2 项目任务本项目实现在 Android移动设备天气预报功能,系统根据用户输入的地址,在Internet上请求获得该地址的天气情况,并发回数据,在系统调用该数据后,将天气实况显示给用户。
2需求分析用户可以使用该系统实现日记的编写,修改和删除,日记内容阅读以及以文本文档形式将日记导入SDcard中。
2.1总体用例图查看当日天气预报查看未来两天天气预报查看地理信息图12.2 天气预报用例图查看当日天气预报2.3天气预报业务流程输入地址选择列表item进入系统进入今日预报页面退出系统图2用户通过点击桌面图标,进入系统。
再通过在文本框中输入的地址,来进入当天天气预报界面。
再点击箭头按钮,页面跳转到未来两天天气预报的界面。
2.4 查看未来两天天气预报用例图2.5 查看未来两天天气预报流程图图22.6 查看地理信息用例图查看未来两天天气预报输入地址选择列表item点击按钮进入系统进入今日预报页面进入明日预报界面退出系统2.7查看地理信息流程图图33 系统设计3.1 天气预报系统UI——登录界面查看地理信息点击MENU 选择MENU 查看地理信息回到系统图43.2天气预报UI——登录界面说明在此界面中,正如大家所见。
含有两个TextView组件,一个ImageView组件,一个AutoCompleteTextView,其字符大小分别是默认的大小。
其中AutoCompleteTextView能够给用户提供选项列表,用户只要单击列表中的一项,此页面就回自动跳转到下一页面。
3.3 天气预报UI——今日天气预报界面图5 图63.4天气预报UI——今日天气预报界面说明此界面中分别含有六个TextView组件,五个ImageView组件,一个ImageButton 组件,一个Menu,在此布局文件中有五个相对布局。
Android 2-1 使用XML解析制作天气预报

2-1 使用XML解析制作天气预报操作指导一、界面布局设计1.界面元素与布局分析图1 界面元素图2 界面布局2.代码需要控件的id3.布局代码<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="/apk/res/android"xmlns:app="/apk/res-auto"xmlns:tools="/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/weather"tools:context=".MainActivity"><TextViewandroid:id="@+id/tv_city"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="20dp"android:layout_marginLeft="50dp"android:layout_marginTop="80dp"android:text="上海"android:textSize="40sp"android:textColor="#ff0505" /><ImageViewandroid:id="@+id/iv_icon"android:layout_width="120dp"android:layout_height="120dp"android:layout_alignLeft="@+id/tv_city"android:layout_below="@+id/tv_city"android:layout_marginBottom="10dp"android:layout_marginLeft="30dp"android:src="@drawable/ic_launcher" /><TextViewandroid:id="@+id/tv_weather"android:layout_width=" wrap_content "android:layout_height="wrap_content"android:layout_below="@+id/iv_icon"android:layout_alignLeft="@+id/iv_icon"android:layout_alignLeft="@+id/iv_icon"android:gravity="center"android:text="多云"android:textSize="18sp" /><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignTop="@+id/iv_icon"android:layout_marginLeft="30dp"android:layout_toRightOf="@+id/iv_icon"android:layout_marginTop="15dp"android:orientation="vertical"><TextViewandroid:id="@+id/tv_temp"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="8dp"android:text="温度:28℃"android:textSize="22sp" /><TextViewandroid:id="@+id/tv_wind"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="8dp"android:text="风力:10级"android:textSize="20sp" /><TextViewandroid:id="@+id/tv_pm"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="PM:80"android:textSize="20sp" /></LinearLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"<Buttonandroid:id="@+id/btn_sh"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="上海" /><Buttonandroid:id="@+id/btn_bj"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="北京" /><Buttonandroid:id="@+id/btn_gz"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="广州" /></LinearLayout></RelativeLayout>二、天气预报数据分析1.数据描述2.数据类型-entity(WeatherInfo)编写一个实体类entity,描述天气信息的类型,包含6个字段:public class WeatherInfo {private String id;private String name;private String weather;private String temp;private String wind;private String pm;public String getId() {return id;}public void setId(String id) {this.id = id;}public String getName() {return name;}public void setName(String name) { = name;}public String getWeather() {return weather;}public void setWeather(String weather) { this.weather = weather;}public String getTemp() {return temp;}public void setTemp(String temp) {this.temp = temp;}public String getWind() {return wind;}public void setWind(String wind) {this.wind = wind;}public String getPm() {return pm;}public void setPm(String pm) {this.pm = pm;}}使用XML文件来描述天气信息。
基于Android平台的天气预报软件设计_毕业设计

本科毕业论文(设计)题目基于Android平台的天气预报软件设计基于Android平台的天气预报软件设计摘要:Google于2008年推出了一款名为Android的开源智能手机操作系统,它采用Linux内核,开放手机联盟(OHA)成员可以任意使用和修改SDK包,系统的开源性使其具有良好的拓展性。
Android的最大特点是其开放性体系架构,不仅具有非常好的开发、调试环境,而且还支持各种可扩展的用户体验。
因此,对于软件从业人员来说,Android平台具有无限的吸引力。
目前Android操作系统已经成为用户最多的智能操作系统。
本天气预报软件的设计,为Android终端用户提供一款方便的实时天气预报查询软件,为用户带来良好的用户体验及便利的对天气情况进行掌控。
本天气预报软件采用ViewFlipper组件,提供友好的界面滑动切换方式,同时减少系统运行时占用的空间。
使用Files方式保存天气信息,Shared Preferences保存用户偏好设置,节约了文件存储的空间。
本文就在分析讨论Android手机软件开发技术原理的基础上,利用Android中基本组件和常用设计模式,开发出能为用户提供更好的基于Android平台的手机天气预报软件。
关键字:Android;天气预报;智能手机平台Design of weather forecast software Based on the Android Abstract:Google in 2008 launched a product called the Android open source smart phone operating system, which uses the Linux kernel, Open Handset Alliance (OHA) members can be free to use and modify the SDK package, open source, it has good scalability of the system. The most important feature of Android is its open architecture, not only has a very good development and debugging environment, but also supports a variety of scalable user experience. Therefore, for software professionals, the Android platform has unlimited appeal. Android operating system has become the user the most intelligent operating system.The weather software designed for the Android end users to provide a convenient, real-time weather query software, to provide users with a good user experience and convenience of control of the weather conditions. The weather forecast software the ViewFlipper components, friendly interface sliding switch, while reducing the space occupied when the system is running. Files saved Weather Information, Shared Preferences to save user preferences settings, save the file storage space. This article on the basis of analysis and discussion of the Android mobile phone software development technical principles, using the basic components and common design patterns Android, developers can provide users with better mobile phone weather forecast software based on the Android platform.Keywords:Android;weather forecast;smart phone platform目录1系统概述 (1)1.1 研究内容 (1)1.2 研究意义 (1)1.3 研究现状和发展趋势 (1)2系统分析 (4)2.1 研究目标 (4)2.2 需求分析 (4)2.3 性能分析 (4)3程序设计 (6)3.1 用户界面设计 (6)3.2 程序模块设计 (9)4程序开发 (10)4.1 文件结构与用途 (10)4.2 数据存储 (13)4.2.1 Shared Preferences (13)4.2.2 Files (14)4.3 主要功能代码 (18)4.3.1 获取天气数据 (18)4.3.2 网络检查 (20)4.3.3 定时更新时间 (21)4.3.4 ViewFlipper手势监听 (21)4.3.5 城市管理中城市点击事件 (23)4.4 主要界面结构布局代码 (24)4.4.1 ViewFlipper框架结构 (25)4.4.2 城市管理界面 (25)4.4.3 生活指数 (26)4.4.4 城市简介 (27)5系统测试 (29)总结 (36)参考文献 (37)致谢 (1)1系统概述1.1 研究内容Android平台手机天气预报软件是基于Android手机平台,运用Java语言,应用/网站上提供的免费的webService接口获取天气预报信息,深入研究Android平台Activity、Service、Broadcast Receiver、Content Provider这四大组件及Android平台的程序运行机制,开发出针对使用Android平台的手机天气预报系统。
《基于Android平台的蒙文天气预报客户端Widget的设计与实现》范文

《基于Android平台的蒙文天气预报客户端Widget的设计与实现》篇一一、引言随着移动互联网的快速发展,天气预报成为了人们日常生活中不可或缺的一部分。
针对蒙文用户,开发一款基于Android平台的蒙文天气预报客户端Widget,不仅能够满足用户对天气信息的即时需求,还能提高用户体验,增强应用的实用性和便捷性。
本文将详细介绍该Widget的设计与实现过程。
二、需求分析1. 用户需求:蒙文用户希望获得实时、准确的天气预报信息,同时希望应用界面友好、操作简便。
2. 功能需求:Widget应具备显示当前天气、未来几天天气预报、生活指数、空气质量等功能。
3. 技术需求:采用Android平台开发,支持蒙文显示,具备较好的兼容性和稳定性。
三、设计思路1. 界面设计:界面应简洁明了,符合蒙文用户的使用习惯。
采用蒙文进行显示,确保用户能够轻松理解应用内容。
2. 功能设计:Widget应具备实时更新天气信息的功能,同时提供多种皮肤和布局选项,以满足用户个性化需求。
3. 技术选型:采用Android Studio开发工具,使用Java或Kotlin语言进行编程,利用Android Weather API获取天气数据。
四、具体实现1. 界面实现:使用XML布局文件定义Widget的界面结构,通过自定义控件和布局实现蒙文显示。
同时,采用Android动画和过渡效果,提高界面的美观性和用户体验。
2. 功能实现:通过调用Android Weather API获取天气数据,并在Widget中实时显示。
实现未来几天天气预报、生活指数、空气质量等功能,为用户提供全面的天气信息。
3. 兼容性和稳定性:针对不同型号和配置的Android设备进行测试,确保Widget具有良好的兼容性和稳定性。
同时,采用异步加载和缓存技术,提高应用的响应速度和性能。
五、测试与优化1. 测试:对Widget进行功能测试、性能测试和兼容性测试,确保应用在各种情况下都能正常运行。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
/einyboy/blog/item/1cb8c9656cb43ffef6365404.htmlAndroid 中文天气预报程序2010年09月13日星期一12:47大家好!由于项目原因好长时间没学android了。
今天抽出点儿时间做个天气预报程序。
贴出来希望对大家有用。
先说一下Google天气预报的AIP吧。
/ig/api?&weather=城市名(中文全拼).我发现在模拟器上面返回的结果和在pc上返回的结果不太一样,pc上有中文的,android 模拟器上没有的。
好了不说别的了。
开始吧!now start。
1。
建立工程。
我取名sbsWeather。
结构如下:我们一步一步来,慢慢完善2。
我习惯先写布局。
1.2.<?xml version="1.0" encoding="utf-8"?>3.<LinearLayout xmlns:android="/apk/res/android"4.android:orientation="vertical"5.android:layout_width="fill_parent"6.android:layout_height="fill_parent"7.>8.<TextView9.android:id="@+id/tvPlace"10.android:layout_width="fill_parent"11.android:layout_height="wrap_content"12./>13.<EditText14.android:id="@+id/place"15.android:layout_width="fill_parent"16.android:layout_height="wrap_content"17.android:hint="输入城市名称(汉字或者拼音)"18./>19.<Button20.android:id="@+id/query"21.android:layout_width="fill_parent"22.android:layout_height="wrap_content"23.android:text="查询"24./>25.</LinearLayout>复制代码3。
我们要做的是中文天气预报哦。
可是Google为我们返回的是中文。
再有我们得把用户输入的中文转换为拼音再传给Google才可以。
现在,需要准备一些工具。
编写中文拼音转换类,CntoEn.java。
网上好多的。
自己随便找一个就哦了。
这个不贴代码了。
搜Java 中文转音频即可。
Utils.java 转换Google返回的英文。
一对一的转换吧,好像没别的跟好的办法。
另外其中还有个方法是将网络图片转换为android的bitmap对象的。
1.2.package com.sbs.weather;3.import java.io.IOException;4.import java.io.InputStream;5.import .HttpURLConnection;6.import .MalformedURLException;7.import .URL;8.import android.graphics.Bitmap;9.import android.graphics.BitmapFactory;10.public class Utils {11.public static String week(String enWeek) {12.if (enWeek.equals("Mon") || enWeek.equals("Monday"))13.return "星期一";14.else if (enWeek.equals("Tue") || enWeek.equals("Tuesday"))15.return "星期二";16.else if (enWeek.equals("Wed") || enWeek.equals("Wednesday"))17.return "星期三";18.else if (enWeek.equals("Thu") || enWeek.equals("Thursday"))19.return "星期四";20.else if (enWeek.equals("Fri") || enWeek.equals("Friday"))21.return "星期五";22.else if (enWeek.equals("Sat") || enWeek.equals("Saturday"))23.return "星期六";24.else if (enWeek.equals("Sun") || enWeek.equals("Sunday"))25.return "星期日";26.return "";27.}28.public static String weather(String enWeather) {29.if (enWeather.equals("Clear"))30.return "晴";31.else if (enWeather.equals("Partly Sunny")32.|| enWeather.equals("partly_cloudy"))33.return "多云";34.else if (enWeather.equals("Chance of Rain"))35.return "晴转雨";36.else if (enWeather.equals("storm"))37.return "暴雨";38.else if (enWeather.equals("thunderstorm"))39.return "雷阵雨";40.else if (enWeather.equals("fog"))41.return "大雾";42.else if (enWeather.equals("haze"))43.return "有雾";44.else if (enWeather.equals("rain"))45.return "雨";46.else if (enWeather.equals("heavyrain"))47.return "大雨";48.else if (enWeather.equals("lightrain"))49.return "小雨";50.else if (enWeather.equals("heavyrain"))51.return "大雨";52.else if (enWeather.equals("snow"))53.return "有雪";54.// / 还需要补充。
55.return "";56.}57.public static Bitmap returnBitMap(String imgUrl) {58.URL myImgUrl = null;59.Bitmap bitmap = null;60.try {61.myImgUrl = new URL(imgUrl);62.} catch (MalformedURLException e) {63.e.printStackTrace();64.}65.try {66.HttpURLConnection conn = (HttpURLConnection) myImgUrl67..openConnection();68.conn.setDoInput(true);69.conn.connect();70.InputStream is = conn.getInputStream();71.bitmap = BitmapFactory.decodeStream(is);72.is.close();73.} catch (IOException e) {74.e.printStackTrace();75.}76.return bitmap;77.}78.}复制代码4。
开始真正的工作咯。
下面的程序通过Google提供的api来获取天气预报信息。
1.package com.sbs.weather;2.3.import java.io.InputStream;4.5.import javax.xml.parsers.DocumentBuilder;6.import javax.xml.parsers.DocumentBuilderFactory;7.8.import org.apache.http.HttpEntity;9.import org.apache.http.HttpResponse;10.import org.apache.http.client.methods.HttpGet;11.import org.apache.http.client.methods.HttpUriRequest;12.import org.apache.http.impl.client.DefaultHttpClient;13.import org.apache.http.util.EntityUtils;14.import org.w3c.dom.Document;15.import org.w3c.dom.NodeList;16.import org.xml.sax.InputSource;17.18.import android.app.Activity;19.import android.graphics.Bitmap;20.import android.os.Bundle;21.import android.os.Handler;22.import android.os.Message;23.import android.util.Log;24.import android.view.View;25.import android.widget.Button;26.import android.widget.EditText;27.import android.widget.ImageView;28.import android.widget.TextView;29.30.public class Weather extends Activity {31.32.public EditText ETplace;33.public TextView TvPlace;34.public Button query;35.public TextView placeName;36.public ImageView imView;37.38./** Called when the activity is first created. */39.@Override40.public void onCreate(Bundle savedInstanceState) {41.super.onCreate(savedInstanceState);42.setContentView(yout.main);43.44.ETplace = (EditText)findViewById(R.id.place);45.query = (Button)findViewById(R.id.query);46.imView = (ImageView)findViewById(R.id.myImageView);47.placeName = (TextView)findViewById(R.id.placeName);48.49.query.setOnClickListener(new Button.OnClickListener() {50.public void onClick(View v) {51.try{Place = (TextView)findViewById(Place);53.54.String place = CntoEn.getFullSpell(ETplace.getText().toString());55.placeName.setText(place);56.String weather = "";57.String url = "/ig/api?&weather="+place;58.DefaultHttpClient client = new DefaultHttpClient();59.HttpUriRequest req = new HttpGet(url);60.HttpResponse resp = client.execute(req);61.62.//String strResult = EntityUtils.toString(resp.getEntity());63.//Log.i("weather->", strResult);64.//一华氏度等于9/5摄氏度数值+3265.66.HttpEntity ent = resp.getEntity();67.InputStream stream = ent.getContent();68.69.DocumentBuilder b = DocumentBuilderFactory.newInstance()70..newDocumentBuilder();71.Document d = b.parse(new InputSource(stream));72.NodeList n = d.getElementsByTagName("forecast_conditions");73.74.// 获得图片url 当天的。