新西兰现在天气的天气是否可以种云豆了

还没有人去过这里
瓦纳卡热门景点
瓦纳卡热门餐饮
瓦纳卡热门折扣
瓦纳卡热门问答
瓦纳卡天气信息
风向东北风
气压1019.2hPa
新西兰其他城市天气
全球热门城市天气
瓦纳卡热门游记攻略
带着父母去旅行,这是我和王桑计划了好久的一件事情。我们两个一起走过很多地方,但陪着爸妈玩的地图基本上连北京都没出过,于是在心中开始酝酿这场孝顺之旅。新西兰是我们两个向往了很久的地方。在我们第一次出国旅行去澳洲时,就想把它安排进来,无奈时间有限只能放弃。想着现在爸妈身体都还不错,先去最远的地方玩没什么问题,所以最后确定就是这片中土世界。惦念了好几年,现在终于可以见面,而且是和爸爸妈妈一起,真的很期待
北京&皇后镇&格林诺奇&皇后镇&箭镇&瓦纳卡&蒂阿瑙&米尔福德峡湾&因弗卡吉尔&但尼丁&奥马鲁&蒂卡普湖&基督城&北京
新婚以来,我最心心念念的,还是蜜月去哪里玩儿这个问题。为了攒到足够的假期,我连举行婚礼时都没有请假,经历了婚礼前倒班儿休半天,婚礼后立刻上班的苦逼日子,我终于在12月份攒出了20天的假期。20天哇!!蜜月必须大规模搞起!!
有了这20天的假期,我立刻把麻袋、毛球、夏威夷等等海岛蜜月胜地全部毖掉——不是说这些地方不好,20天泡在一个小岛上,没被憋死也会被穷死哇~此类海岛还是待我用小长假来一一征服吧~
北京&新加坡&基督城&Akaroa&Kaikoura&Hokitika&FoxGlacier&Wanaka&Arrowtown&Queenstown&TeAnau&McleanFalls&NuggetPoint&OtagoPeninsula&Oamaru&Twizel&Tekapo&基督城&新加坡&北京
先晒一下行程路线(编辑行程单一个个添加,刚好有些名字又打出来没有的,还是在前面再发一下路线图吧)4.3/4.4 北京-广州-奥克兰-基督城4.5 基督城-薄饼岩-霍基蒂卡4.6 霍基蒂卡-弗朗兹.约瑟夫冰川4.7 弗朗兹.约瑟夫冰川-马瑟森湖-瓦纳卡4.8 瓦纳卡-蒂阿瑙4.9 蒂阿瑙-米尔福德峡湾-因佛卡吉尔4.10 因佛卡吉尔-南部观景线-纳吉特角4.11 纳吉特角-但尼丁-皇后镇4.12 皇
北京&广州&奥克兰&基督城&霍基蒂卡&普纳凯基&霍基蒂卡&弗朗茨约瑟夫冰川&瓦纳卡&福克斯冰川&瓦纳卡&蒂阿瑙&因弗卡吉尔&蒂阿瑙&米尔福德峡湾&因弗卡吉尔&但尼丁&皇后镇&瓦纳卡&皇后镇&箭镇&瓦纳卡&库克山镇&蒂卡普湖&基督城&阿卡罗阿&基督城&北京
更多瓦纳卡游记攻略
/weather/9168/查看: 453|回复: 1
Android 天气预报 完整案例详解
TA的每日心情开心7&小时前签到天数: 191 天[LV.7]常住居民III
本帖最后由 Dobbie 于
21:12 编辑
第七部分 天气预报
& &要实现一个天气预报的应用,首先需要找到一个提供天气信息的Web服务。
& &Google提供的天气预报,其获取方式有两种:
& & 1、通过经纬度来定位获得该地区的天气信息。
& &&&在浏览器中输入 (4019996分别表示经度和纬度的数据),即可获得一个XML形式的
& &&&数据,其中包括了天气信息。通过网络获得这些信息后,再将这些xml信息进行解析就可以得到我们需要的天气信息了
& & 2、通过城市的名字来获取天气信息
& &&&在浏览器中输入 (chengdu代表城市的名字,此处为成都)
& &&&这两种方式都获得如下信息& &&&&font face=&宋体& size=&3&&&font face=&宋体& size=&3&&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& &&&&?xml version=&1.0&?&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &-&xml_api_reply version=&1&&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && & -&weather section=&0& row=&0& mobile_zipped=&1& mobile_row=&0& tab_id=&0& module_id=&0&&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &&&-&forecast_information&& &//forecast_information表示当前的一些信息,比如城市、时间等&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&city data=&&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&postal_code data=&&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&latitude_e6 data=&&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&longitude_e6 data=&&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&forecast_date data=&&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&current_date_time data=& 18:00:00 +0000&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&unit_system data=&SI&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &&&&/forecast_information&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &&&-&current_conditions&& &//current_conditions表示当前的实时天气预报&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&condition data=&雾霾&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&temp_f data=&50&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&temp_c data=&10&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&humidity data=&湿度: 58%&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&icon data=&/ig/images/weather/haze.gif&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&wind_condition data=&风向: 北、风速:1 米/秒&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &&&&/current_conditions&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &&&-&forecast_conditions& //如下四个forecast_conditions表示预报的后4天的天气信息&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&day_of_week data=&周四&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&low data=&6&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&high data=&10&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&icon data=&/ig/images/weather/mostly_sunny.gif&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&condition data=&以晴为主&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &&&&/forecast_conditions&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &&&-&forecast_conditions&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&day_of_week data=&周五&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&low data=&5&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&high data=&10&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&icon data=&/ig/images/weather/chance_of_rain.gif&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&condition data=&可能有雨&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&/forecast_conditions&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &&&-&forecast_conditions&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&day_of_week data=&周六&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&low data=&5&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&high data=&8&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&icon data=&/ig/images/weather/chance_of_rain.gif&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&condition data=&可能有雨&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&/forecast_conditions&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &&&-&forecast_conditions&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&day_of_week data=&周日&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&low data=&3&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&high data=&9&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&icon data=&/ig/images/weather/mostly_sunny.gif&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && && &&condition data=&晴间多云&/&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &&&&/forecast_conditions&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && & &/weather&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &&/xml_api_reply&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& & &/span&&/font&&/font&复制代码
& & 通过上面找到信息来源后就需要根据信息的内容来设计适合我们程序的界面。
& & 分析上面信息包括了最高 最低温度、一个ICNO图标(表示天气信息的小图标)、一些附加的描述。也就是说,我们至少需要一个ImageView来显示这些图标,一个TextView来显示
& & 温度和附加消息&font face=&宋体& size=&3&&&font face=&宋体& size=&3&&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& & public class SingleWeatherInfoView extends LinearLayout{//创建此类来定义一个线性布局以显示所获得的信息&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& &&&private ImageView myWeatherImageView =&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& &&&private TextView myTempTextView&&=&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& &&&public SingleWeatherInfoView(Context context){&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &super(context);&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& &&&}&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& &&&public SingleWeatherInfoView(Context context, AttributeSet attrs){&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &super(context, attrs);&&&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &this.myWeatherImageView = new ImageView(context);&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &this.myWeatherImageView.setPadding(10, 5, 5, 5);&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &this.myTempTextView = new TextView(context);&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &this.myTempTextView.setTextColor(R.color.black);&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &this.myTempTextView.setTextSize(16);&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &this.addView(this.myWeatherImageView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &this.addView(this.myTempTextView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& &&&}&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& &&&public void setWeatherString(String aWeatherString){&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &this.myTempTextView.setText(aWeatherString);&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& &&&}&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& &&&public void setWeatherIcon(URL aURL){//此ImageView是通过网络获取的图片,所以定义了setWeatherIcon方法来专门设置图片&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &try{&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && & URLConnection conn = aURL.openConnection();&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && & conn.connect();&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && & InputStream is = conn.getInputStream();&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && & BufferedInputStream bis = new BufferedInputStream(is);&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && & Bitmap bm = BitmapFactory.decodeStream(bis);&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && & bis.close();&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && & is.close();&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && & this.myWeatherImageView.setImageBitmap(bm);&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& && &}catch (Exception e){}&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& &&&}&/span&
&span style=&color: rgb(51, 51, 51); line-height: 26&&& & }&/span&&/font&&/font&复制代码
& &res.layout.main.xml&font face=&宋体& size=&3&&&font face=&宋体& size=&3&&
& &&?xml version=&1.0& encoding=&utf-8&?&
& & &LinearLayout
& &&&xmlns:android=&&a href=&/apk/res/android& style=&text-decoration:&&/apk/res/android&/a&&
& &&&android:orientation=&vertical&
& &&&android:layout_width=&fill_parent&
& &&&android:layout_height=&fill_parent&
& &&&android:background=&@drawable/bg&&
& &&&&TextView
& && &android:id=&@+id/TextView001&
& && &android:layout_width=&wrap_content&
& && &android:layout_height=&wrap_content&
& && &android:text=&@string/inputstr&
& && &android:textStyle=&bold&
& && &android:textSize=&16px&
& && &android:layout_marginLeft=&10px&
& && &android:textColor=&@color/black&&
& &&&&/TextView&
& &&&&TableLayout
& && &android:id=&@+id/TableLayout02&
& && &android:layout_height=&wrap_content&
& && &android:layout_width=&fill_parent&&
& && &&TableRow
& && & android:id=&@+id/TableRow01&
& && & android:layout_height=&wrap_content&
& && & android:layout_width=&fill_parent&&
& && & &TextView
& && &&&android:id=&@+id/TextView01&
& && &&&android:layout_width=&wrap_content&
& && &&&android:layout_height=&wrap_content&
& && &&&android:text=&@string/msg&
& && &&&android:textStyle=&bold&
& && &&&android:textSize=&16px&
& && &&&android:layout_marginLeft=&10px&
& && &&&android:textColor=&@color/black&&
& && & &/TextView&
& && & &Spinner //本例中使用两种方式来获取信息,一个通过Spinner来显示一些城市供用户选择,一个通过EditText供用户输入城市名字
& && &&&android:id=&@+id/Spinner01&
& && &&&android:layout_height=&wrap_content&
& && &&&android:layout_width=&fill_parent&
& && &&&android:paddingLeft=&10px&
& && &&&android:minWidth=&200px&&
& && & &/Spinner&
& && & &Button
& && &&&android:id=&@+id/Button01&
& && &&&android:layout_width=&wrap_content&
& && &&&android:layout_height=&wrap_content&
& && &&&android:text=&@string/OK&
& && &&&android:paddingLeft=&10px&&
& && & &/Button&
& && &&/TableRow&
& &&&&/TableLayout&
& &&&&TableLayout
& && &android:id=&@+id/TableLayout002&
& && &android:layout_height=&wrap_content&
& && &android:layout_width=&fill_parent&&
& && &&TableRow
& && & android:id=&@+id/TableRow001&
& && & android:layout_height=&wrap_content&
& && & android:layout_width=&fill_parent&&
& && & &TextView
& && &&&android:id=&@+id/TextView002&
& && &&&android:layout_width=&wrap_content&
& && &&&android:layout_height=&wrap_content&
& && &&&android:text=&@string/msg&
& && &&&android:textStyle=&bold&
& && &&&android:textSize=&16px&
& && &&&android:layout_marginLeft=&10px&
& && &&&android:textColor=&@color/black&&
& && & &/TextView&
& && & &EditText //本例中使用两种方式来获取信息,一个通过Spinner来显示一些城市供用户选择,一个通过EditText供用户输入城市名字
& && &&&android:id=&@+id/EditText001&
& && &&&android:layout_height=&wrap_content&
& && &&&android:layout_width=&fill_parent&
& && &&&android:paddingLeft=&10px&
& && &&&android:minWidth=&200px&&
& && & &/EditText&
& && & &Button
& && &&&android:id=&@+id/Button001&
& && &&&android:layout_width=&wrap_content&
& && &&&android:layout_height=&wrap_content&
& && &&&android:text=&@string/OK&
& && &&&android:paddingLeft=&10px&&
& && & &/Button&
& && &&/TableRow&
& &&&&/TableLayout&
& &&&&TableLayout
& && &android:id=&@+id/TableLayout01&
& && &android:layout_width=&fill_parent&
& && &android:layout_height=&wrap_content&&
& && &&TableRow
& && & android:id=&@+id/TableRow02&
& && & android:layout_width=&wrap_content&
& && & android:layout_height=&wrap_content&&
& && & &com.yarin.android.CityWeather.SingleWeatherInfoView
& && &&&android:id=&@+id/weather_0&
& && &&&android:layout_width=&wrap_content&
& && &&&android:layout_height=&wrap_content&/&
& && &&/TableRow&
& && &&TableRow
& && & android:id=&@+id/TableRow03&
& && & android:layout_width=&wrap_content&
& && & android:layout_height=&wrap_content&&
& && & &com.yarin.android.CityWeather.SingleWeatherInfoView
& && &&&android:id=&@+id/weather_1&
& && &&&android:layout_width=&wrap_content&
& && &&&android:layout_height=&wrap_content&/&
& && &&/TableRow&
& && &&TableRow
& && & android:id=&@+id/TableRow04&
& && & android:layout_width=&wrap_content&
& && & android:layout_height=&wrap_content&&
& && & &com.yarin.android.CityWeather.SingleWeatherInfoView
& && &&&android:id=&@+id/weather_2&
& && &&&android:layout_width=&wrap_content&
& && &&&android:layout_height=&wrap_content&/&
& && &&/TableRow&
& && &&TableRow
& && & android:id=&@+id/TableRow05&
& && & android:layout_width=&wrap_content&
& && & android:layout_height=&wrap_content&&
& && & &com.yarin.android.CityWeather.SingleWeatherInfoView
& && &&&android:id=&@+id/weather_3&
& && &&&android:layout_width=&wrap_content&
& && &&&android:layout_height=&wrap_content&/&
& && &&/TableRow&
& && &&TableRow
& && & android:id=&@+id/TableRow06&
& && & android:layout_width=&wrap_content&
& && & android:layout_height=&wrap_content&&
& && & &com.yarin.android.CityWeather.SingleWeatherInfoView
& && &&&android:id=&@+id/weather_4&
& && &&&android:layout_width=&wrap_content&
& && &&&android:layout_height=&wrap_content&/&
& && &&/TableRow&
& &&&&/TableLayout&
& & &/LinearLayout&
& &&/font&&/font&复制代码
& &XML文件解析
& & 三种解析XML文件的方法
& & 1、使用DOM方式来解析XML
& && &DOM是Document Object Model的缩写,即文档对象模型。XML将数据组织为一颗树,所以DOM就是对这颗树的一个对象描述。就是通过解析XML文档,为XML文档在逻辑上
& &&&建立一个树模型,树的节点是一个个对象。通过对存取这些对象就能够存取XML文档的内容。DOM解析器是通过将XML文档解析成树状模型并将其放入内存来完成解析工作的。
& &&&而后对文档的操作都是在这个树状模型上完成的。这个在内存中的文档是文档实际大小的几倍。这样的好处是结构清晰、操作方便,但极其耗系统资源。
& && &使用DOM方式解析xml需如下两个包
& && & import javax.xml.parsers.*;//此包包含DOM解析器和SAX解析器的具体实现
& && & import org.w3c.dom.*;//此包定义了W3C所制定的DOM接口。
& && &要想对XML的内容进行解析,首先需要创建一个DocumentBuilderFactory(工厂对象) 代码如下:&font face=&宋体& size=&3&&&font face=&宋体& size=&3&&
& && & DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();//使用DocumentBuilderFactory是为了创建与具体解析器无关的程序,当DocumentBuilderFactory
& && && && && && && & 的静态方法newInstance()被调用时,它根据一个系统变量来决定具体使用哪一个解析器。又因为所有的
& && && && && && && & 解析器都服从JAXP所定义的接口,所以无论具体使用哪一个解析器,代码都是一样的。所以当在不同的
& && && && && && && & 解析器之间进行切换时,只需要更改系统变量的值,而不用更改任何代码。这就是工厂对象所带来的好处
& && & DocumentBuilder db = dbf.newDocumentBuilder();//得到一个工厂对象后,使用它的静态方法newDocumentBuilder()可获得DocumentBuilder对象,这个对象代表了具体的
& && && && && && & DOM解析器
& && & Document doc = db.parse(&xxxx.xml&);//利用上面的解析器对XML文档进行解析,DocumentBuilder的Parse()方法接收一个XML文档名作为输入参数,返回一个Document对象
& && && && && & ,这个Document对象就代表一个XML文档的树模型。以后所有对XML文档的操作,都与解析器无关。直接对Cocument对象操作就行了。
& && & doc.normalize();//对Document操作的具体方法,由DOM所以定义的。Document中的normalize方法可以去掉XML文档中作为格式化内容的空白而映射到DOM树中的不
& && && &&&必要的TextNode对象
& && & NodeList nodelist = doc.getElementsByTagName(&节点&);//通过Document的getElementByTagName获取一个节点NodeList对象
& && &
& && & for(int i = 0; i&nodelist.getLength(); i++){//通过item()方法提取想要的元素,并输出每个元素的数据。这样就可以得到我们想要的数据了,还可以修改一个
& && && && && && & DOM树中的值,然后重新写入到一个XML文件中去。
& && &&&Element element = (Element)nodelist.item(i);
& && &&&String str = element.getElementsByTagName(&元素名称&).item(0).getFirstChild().getNodeValue();
& && & }
& && & &/font&&/font&复制代码
& && & 此处是创建了一个节点并对其进行了赋值&font face=&宋体& size=&3&&&font face=&宋体& size=&3&&
& && & Element element = doc.createElement(&节点&);//Document的createElement方法可以创建一个元素
& && & Element elementtext = doc.createElement(&text&);
& && & String textseg = doc.createTextNode(text);
& && & elementtext.appendChild(textseg);
& && & element.appendChild(elementtext);
& && & &/font&&/font&复制代码
& && & 在创建好节点之后,就可以将修改的内容写入到XML文件中。Transformer类的 transform 方法接收两个参数、一个数据源Source和一个输出目标Result.
& && & 下面中使用了DOMSource和StreamResult作为数据源和输出目标,这样就把DOM的内容输出到一个输出流中,当这个输出流式一个文件的时候,DOM的内容
& && & 就被写入到文件中去了。代码如:&font face=&宋体& size=&3&&&font face=&宋体& size=&3&&
& && &&&TransformerFactory tFactory = TransformerFactory.newInstance();
& && &&&Transformer transformer = tFactory.newTransformer();
& && &&&DOMSource source = new DOMSource(doc);
& && &&&StreamResult result =new StreamResult(new java.io.File.(&text.xml&));
& && &&&transformer.transform(source, result);&/font&&/font&复制代码
& & 2、使用XmlPullParser来解析XML
& &&&XmlPullParser解析器其工作方式类似于SAX.它允许应用程序从解析器中获取事件,这与SAX解析器自动将事件推入处理程序相反。
& &&&下例为使用XmlPullParser来解析一个XML文件的方法&font face=&宋体& size=&3&&&font face=&宋体& size=&3&&
& && &Public void getXML(String url) throws XmlPullParserException,IOException, URISyntaxException{
& && & XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
& && & factory.setNamespaceAware(true);
& && & XmlPullParser parser = factory.newPullParser();
& && & parser.setInput(new InputStreamReader(getUrlData(url)));
& && & XmlUtils.beginDocument(parser, &results&);
& && & int eventType = parser.getEventType();
& && & do{
& && &&&XmlUtils.nextElement(parser);
& && &&&parser.next();//XmlPullParser解析器的运行方式与SAX解析器相似。它提供了类似的事件(开始元素和结束元素),
& && && && && && &但需要使用Parser.next()方法来提取它们。事件将作为数值代码被发送
& && && && && && &因此可以根据不同的事件代码值来进行不同的处理。
& && &&&eventType = parser.getEventType();//此方法用来取得事件的代码值(如:XmlPullParser.START_DOCUMENT、XmlPullParser.START_TAG、XmlPullParser.END_TAG.)
& && && && && &&&解析并为像SAX解析那样监听元素的结束,而是在开始处完成了大部分处理。当某个元素开始是,可以调用
& && && && && &&&parser.nextText()从XML文档中提取所有的字符数据。
& && &&&if(eventType == XmlPullParser.TEXT){
& && && &String str= &&;
& && && &str += parser.getText();
& && &&&}
& && & }while(eventType != XmlPullParser.END_DOCUMENT);
& && &}&/font&&/font&复制代码
& &&&同样还可以使用XmlPullParser来创建XML文档,要创建XML文档需要使用StringBuilder来创建XML字符串。
& &&&下例使用XmlPullParser解析器来创建一个XML文件并写入数据&font face=&宋体& size=&3&&&font face=&宋体& size=&3&&
& && &private String writeXml(List&Message& messages){
& && & XmlSerializer serializer = Xml.newSerializer();
& && & StringWriter writer = new StringWriter();
& && & try{
& && &&&serializer.setOutput(writer);
& && &&&serializer.startDocument(&UTF-8&, true);
& && &&&serializer.startTag(&&, &messages&);
& && &&&serializer.attribute(&&, &number&, String.valueOf(messages.size()));
& && &&&for(Message msg: messages){
& && && &serializer.startTag(&&, &message&);
& && && &serializer.attribute(&&, &date&, msg.getDate());
& && && &serializer.startTag(&&, &titile&);
& && && &serializer.text(msg.getTitle());
& && && &serializer.endTag(&&, &title&);
& && && &serializer.startTag(&&,&url&);
& && && &serializer.text(msg.getLink().toExternalForm());
& && && &serializer.ednTag(&&, &url&);
& && && &serializer.startTag(&&, &body&);
& && && &serializer.text(msg.getDescription());
& && && &serializer.endTag(&&, &body&);
& && && &serializer.endTag(&&,&message&);
& && &&&}
& && &&&serializer.endTag(&&,&message&);
& && &&&serializer.endDocument();
& && &&&return writer.toString();
& && & }catch(Exception e){
& && &&&throw new RuntimeException(e);
& && & }
& && &}&/font&&/font&复制代码
& & 3、使用SAX来解析XML文件
& &&&当需要一个速度快的解析器并且希望最大限度的减少应用程序的内存占用时,可以使用SAX 来解析,这种非常适合Android的移动设备。
& &&&SAX是Simple API for XML的缩写。与DOM比较 SAX是一种轻量级的方法。我们知道处理DOM的时候,需要读入整个XML文档,然后在内存中创建DOM树,生成DOM树上的每个Node
& &&&对象。当文档比较小时,这不成问题。当文档比较大时,处理DOM就变得相当费时,费力。特别是内存方面将成倍的增加。这时就要考虑用SAX了。
& &&&这三种方式各有各自的优确定。大多数情况下使用SAX比较安全的。Android也提供了一种传统的SAX使用方法以及一个便捷的SAX包装器。如果文档比较小,那么DOM可能是一种
& &&&比较简单的方法。如果文档比较大,但只需要文档的一部分,则XML PULL解析器可能更有效。
& & 本例是使用SAX来解析xml文件的&font face=&宋体& size=&3&&&p style=&color: rgb(51, 51, 51); line-height: 26&&&font face=&宋体& size=&3&&
& & public class GoogleWeatherHandler extends DefaultHandler{
& &&&private WeatherSet&&myWeatherSet& &=//天气信息
& &&&private boolean& &is_Current_Conditions =//实时天气信息
& &&&private boolean& &is_Forecast_Conditions =//预报天气信息
& &&&private final String CURRENT_CONDITIONS&&= &current_conditions&;
& &&&private final String FORECAST_CONDITIONS&&= &forecast_conditions&;&/font&&/p&&p style=&color: rgb(51, 51, 51); line-height: 26&&&font face=&宋体& size=&3&&& &&&public GoogleWeatherHandler(){
& &&&}
& &&&public WeatherSet getMyWeatherSet(){//返回天气信息对象
& && &return myWeatherS
& &&&}
& &&&public void endDocument() throws SAXException{
& && &super.endDocument();
& &&&}
& &&&public void endElement(String uri, String localName, String name) throws SAXException{
& && &if (localName.equals(CURRENT_CONDITIONS)){
& && & this.is_Current_Conditions =
& && &}else if (localName.equals(FORECAST_CONDITIONS)){
& && & this.is_Forecast_Conditions =
& && &}
& &&&}
& &&&public void startDocument() throws SAXException{
& && &this.myWeatherSet = new WeatherSet();
& &&&}
& &&&public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException{//在所得到的信息中,当解析开始时遇到一个
& && && && && && && && &开始标签时候,在此方法中可以根据不同的标签来取得不同的数据消息存放到一个我们
& && && && && && && && &自定义的用来保存获取天气信息的WeatherSet类中
& && &if (localName.equals(CURRENT_CONDITIONS)){//实时天气
& && & Log.i(&localName+CURRENT&, localName);
& && & this.myWeatherSet.setMyCurrentCondition(new WeatherCurrentCondition());
& && & Log.i(&localName+CURRENT+1&, localName);
& && & this.is_Current_Conditions =
& && &}else if (localName.equals(FORECAST_CONDITIONS)){//预报天气
& && & this.myWeatherSet.getMyForecastConditions().add(new WeatherForecastCondition());
& && & this.is_Forecast_Conditions =
& && &}else{
& && & if (localName.equals(CURRENT_CONDITIONS)){//分别将得到的信息设置到指定的对象中
& && & Log.i(&localName+CURRENT&, localName);
& && & }
& && & String dataAttribute = attributes.getValue(&data&);
& && & if (localName.equals(&icon&)){
& && &&&if (this.is_Current_Conditions){
& && && &this.myWeatherSet.getMyCurrentCondition().setIcon(dataAttribute);
& && &&&}else if (this.is_Forecast_Conditions){
& && && &this.myWeatherSet.getLastForecastCondition().setIcon(dataAttribute);
& && &&&}
& && & }else if (localName.equals(&condition&)){
& && &&&if (this.is_Current_Conditions){
& && && &this.myWeatherSet.getMyCurrentCondition().setCondition(dataAttribute);
& && &&&}else if (this.is_Forecast_Conditions){
& && && &this.myWeatherSet.getLastForecastCondition().setCondition(dataAttribute);
& && &&&}
& && & }else if (localName.equals(&temp_c&)){
& && &&&this.myWeatherSet.getMyCurrentCondition().setTemp_celcius(dataAttribute);
& && & }else if (localName.equals(&temp_f&)){
& && &&&this.myWeatherSet.getMyCurrentCondition().setTemp_fahrenheit(dataAttribute);
& && & }else if (localName.equals(&humidity&)){
& && &&&this.myWeatherSet.getMyCurrentCondition().setHumidity(dataAttribute);
& && & }else if (localName.equals(&wind_condition&)){
& && &&&this.myWeatherSet.getMyCurrentCondition().setWind_condition(dataAttribute);
& && & }else if (localName.equals(&day_of_week&)){// Tags is forecast_conditions
& && &&&this.myWeatherSet.getLastForecastCondition().setDay_of_week(dataAttribute);
& && & }else if (localName.equals(&low&)){
& && &&&this.myWeatherSet.getLastForecastCondition().setLow(dataAttribute);
& && & }else if (localName.equals(&high&)){
& && &&&this.myWeatherSet.getLastForecastCondition().setHigh(dataAttribute);
& && & }
& && &}
& &&&}
& &&&public void characters(char ch[], int start, int length){
& && & /*
& && & * Would be called on the following structure:
& && & * &element&characters&/element&
& && & */
& &&&}
& & }&/font&&/p&&/font&复制代码
& & 以上使用了同DOM一样的设计技巧,在创建SAXParser对象的时候,通过一个SAXParserFactory类来创建具体的SAXParser对象,这样当需要使用不同的解析器的时候,只要改变
& & 一个环境变量的值,而程序的代码可以保存不变。代码如下:
& &&&SAXParserFactory spf = SAXParserFactory.newInstance();
& & 在获得了SAXParserFactory对象之后,要解析XML还需要一个SAXParser或者XMLReader,SAXParser是JAXP中对XMLReader的一个封装类,而XMLReader是定义在SAX2.0中的一个用
& & 来解析文档的接口。你可以同样调用SAXParser或者XMLReader中的parser()方法来解析文档,效果是完全一样的。不过SAXParser中的parser()方法接收更多的参数,可以对不同的
& & XML文档数据源进行解析,因而使用起来要比XMLReader方便些
& &&&SAXParser sp = spf.newSAXParser();
& &&&XMLReader xr = spf.getXMLReader();
& & 在创建了XMLReader之后,就可以使用上一个步骤创建的GoogleWeatherHandler来解析XML代码如下:
&font face=&宋体& size=&3&&&font face=&宋体& size=&3&&&span style=&color: rgb(51, 51, 51); line-height: 26 background-color: rgb(255, 255, 255);&&& & &/span&&span style=&color: rgb(51, 51, 51); line-height: 26&& GoogleWeatherHandler gwh =new GoogleWeahterHandler();&/span&&/font&&p style=&color: rgb(51, 51, 51); line-height: 26&&&font face=&宋体& size=&3&&&&xr.setContentHandler(gwh);
& &&&InputStreamReader isr = new InputStreamReader(url.openStream(),&GBK&);
& &&&InputSource is = new InputSource(isr);
& &&&xr.parse(is);
& &&&
& & public class WeatherSet{我们自定义的用来保存获取天气信息的WeatherSet类中
& &&&private WeatherCurrentCondition myCurrentCondition = //实时天气信息
& &&&private ArrayList&WeatherForecastCondition& myForecastConditions = new ArrayList&WeatherForecastCondition&();//预报的后四天的天气信息&&
& &&&public WeatherSet(){
& &&&}&&
& &&&public WeatherCurrentCondition getMyCurrentCondition(){ //得到实时天气信息的对象
& && &return myCurrentC
& &&&}
& &&&public void setMyCurrentCondition(WeatherCurrentCondition myCurrentCondition){//设置实时天气信息的对象
& && &this.myCurrentCondition = myCurrentC
& &&&}
& &&&public ArrayList&WeatherForecastCondition& getMyForecastConditions(){//得到预报天气
& && &return myForecastC
& &&&}
& &&&public WeatherForecastCondition getLastForecastCondition(){//得到最后一个预报天气,这里我们每次添加一个数据都是在最后,所以得到最后一个
& && &return myForecastConditions.get(myForecastConditions.size() - 1);
& &&&}
& & }&/font&&/p&&p style=&color: rgb(51, 51, 51); line-height: 26&&&font face=&宋体& size=&3&&& & package com.yarin.android.CityW
& & //实时天气信息处理(当前天气信息)
& & /**
& & &current_conditions&
& &&&&condition data=&多云&/&
& &&&&temp_f data=&88&/&
& &&&&temp_c data=&31&/&
& &&&&humidity data=&湿度: 58%&/&
& &&&&icon data=&/ig/images/weather/cn_cloudy.gif&/&
& &&&&wind_condition data=&风向: 东、风速:4 米/秒&/&
& &&&&/current_conditions&
& & */
& & public class WeatherCurrentCondition{
& &&&private S& &// 多云
& &&&private String temp_&&// 摄氏温度
& &&&private String temp_ // 华氏温度
& &&&private S& &// 湿度:58%
& &&&private String wind_&&// 风向...
& &&&private S& & // 图标
& &&&public WeatherCurrentCondition(){
& &&&}
& &&&public String getCondition(){//得到Condition(多云)
& && &
& &&&}
& &&&public void setCondition(String condition){//设置Condition(多云)
& && &this.condition =
& &&&}
& &&&public String getTemp_c(){//得到设置温度
& && &return temp_
& &&&}
& &&&public String getTemp_f(){//得到华氏温度
& && &return temp_
& &&&}
& &&&public void setTemp_celcius(String temp_celcius){//设置摄氏温度
& && &this.temp_celcius = temp_
& &&&}
& &&&public void setTemp_fahrenheit(String temp_fahrenheit){//设置华氏温度
& && &this.temp_fahrenheit = temp_
& &&&}
& &&&public String getHumidity(){//得到(湿度:58%)
& && &
& &&&}
& &&&public void setHumidity(String humidity){//设置(湿度:58%)
& && &this.humidity =
& &&&}
& &&&public String getWind_condition(){//得到风向指示
& && &return wind_
& &&&}
& &&&public void setWind_condition(String wind_condition){//设置风向指示
& && &this.wind_condition = wind_
& &&&}
& &&&public String getIcon(){//得到图标地址
& && &
& &&&}
& &&&public void setIcon(String icon){//设置图标地址
& && &this.icon =
& &&&}
& &&&public String toString(){//得到一个封装打包的字符串,包括除icno外的所有东西
& && &StringBuilder sb = new StringBuilder();
& && &sb.append(&实时天气: &).append(temp_celcius).append(& °C&);
& && &sb.append(& &).append(temp_fahrenheit).append(& F&);
& && &sb.append(& &).append(condition);
& && &sb.append(& &).append(humidity);
& && &sb.append(& &).append(wind_condition);
& && &return sb.toString();
& &&&}
& & }&/font&&/p&&p style=&color: rgb(51, 51, 51); line-height: 26&&&font face=&宋体& size=&3&&& & package com.yarin.android.CityW
& & //预报后四天的天气信息
& & /**
& & &forecast_conditions&
& &&&&day_of_week data=&周二&/&
& &&&&low data=&24&/&
& &&&&high data=&33&/&
& &&&&icon data=&/ig/images/weather/chance_of_rain.gif&/&
& &&&&condition data=&可能有雨&/&
& & &/forecast_conditions&
& & */
& & public class WeatherForecastCondition {
& &&&private String day_of_&&//星期
& &&&private S& & //最低温度
& &&&private S& &//最高温度
& &&&private S& &//图标
& &&&private S&&//提示
& &&&public WeatherForecastCondition(){
& &&&}
& &&&public String getCondition(){
& && &
& &&&}
& &&&public void setCondition(String condition){
& && &this.condition =
& &&&}
& &&&public String getDay_of_week(){
& && &return day_of_
& &&&}
& &&&public void setDay_of_week(String day_of_week){
& && &this.day_of_week = day_of_
& &&&}
& &&&public String getLow(){
& && &
& &&&}
& &&&public void setLow(String low){
& && &this.low =
& &&&}
& &&&public String getHigh(){
& && &
& &&&}
& &&&public void setHigh(String high){
& && &this.high =
& &&&}
& &&&public String getIcon(){
& && &
& &&&}
& &&&public void setIcon(String icon){
& && &this.icon =
& &&&}
& &&&public String toString(){
& && &StringBuilder sb = new StringBuilder();
& && &sb.append(& &).append(day_of_week);
& && &sb.append(& : &).append(high);
& && &sb.append(&/&).append(low).append(& °C&);
& && &sb.append(& &).append(condition);
& && &return sb.toString();
& &&&}
& & }&/font&&/p&&p style=&color: rgb(51, 51, 51); line-height: 26&&&font face=&宋体& size=&3&&& & public class CityWeather extends Activity{
& &&&public void onCreate(Bundle savedInstanceState){
& && &super.onCreate(savedInstanceState);
& && &setContentView(R.layout.main);
& && &init();
& &&&}
& &&&private void init(){
& && &Spinner city_spr = (Spinner) findViewById(R.id.Spinner01);
& && &ArrayAdapter&String& adapter = new ArrayAdapter&String&(this, android.R.layout.simple_spinner_item, ConstData.city);
& && &adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
& && &city_spr.setAdapter(adapter);&/font&&/p&&p style=&color: rgb(51, 51, 51); line-height: 26&&&font face=&宋体& size=&3&&& && &Button submit = (Button) findViewById(R.id.Button01);
& && &submit.setOnClickListener(new OnClickListener() {
& && & public void onClick(View v){
& && &&&Spinner spr = (Spinner) findViewById(R.id.Spinner01);
& && &&&Long l = spr.getSelectedItemId();
& && &&&int index = l.intValue();
& && &&&String cityParamString = ConstData.cityCode[index];
& && &&&try{
& && && &URL url = new URL(ConstData.queryString + cityParamString);
& && && &getCityWeather(url);
& && &&&}catch (Exception e){
& && && &Log.e(&CityWeather&, e.toString());
& && &&&}
& && & }
& && &});
& && &Button submit_input = (Button) findViewById(R.id.Button001);
& && &submit_input.setOnClickListener(new OnClickListener(){
& && & public void onClick(View v) {
& && &&&EditText inputcity = (EditText) findViewById(R.id.EditText001);
& && &&&String tmp = inputcity.getText().toString();
& && &&&try{
& && && &URL url = new URL(ConstData.queryString_intput + tmp);
& && && &getCityWeather(url);
& && &&&}catch (Exception e){
& && && &Log.e(&CityWeather&, e.toString());
& && &&&}
& && & }
& && &});
& &&&}
& &&&private void updateWeatherInfoView(int aResourceID, WeatherCurrentCondition aWCC) throws MalformedURLException{// 更新显示实时天气信息
& && &URL imgURL = new URL(&&a href=&/& style=&text-decoration:&&/&/a&& + aWCC.getIcon());
& && &((SingleWeatherInfoView) findViewById(aResourceID)).setWeatherIcon(imgURL);
& && &((SingleWeatherInfoView) findViewById(aResourceID)).setWeatherString(aWCC.toString());
& &&&}
& &&&private void updateWeatherInfoView(int aResourceID, WeatherForecastCondition aWFC) throws MalformedURLException{// 更新显示天气预报
& && &URL imgURL = new URL(&&a href=&/& style=&text-decoration:&&/&/a&& + aWFC.getIcon());
& && &((SingleWeatherInfoView) findViewById(aResourceID)).setWeatherIcon(imgURL);
& && &((SingleWeatherInfoView) findViewById(aResourceID)).setWeatherString(aWFC.toString());
& &&&}
& &&&//获取天气信息
& &&&//通过网络获取数据
& &&&//传递给XMLReader解析
& &&&public void getCityWeather(URL url){
& && &try{
& && & SAXParserFactory spf = SAXParserFactory.newInstance();
& && & SAXParser sp = spf.newSAXParser();
& && & XMLReader xr = sp.getXMLReader();
& && & GoogleWeatherHandler gwh = new GoogleWeatherHandler();
& && & xr.setContentHandler(gwh);
& && & InputStreamReader isr = new InputStreamReader(url.openStream(), &GBK&);
& && & InputSource is = new InputSource(isr);
& && & xr.parse(is);
& && & WeatherSet ws = gwh.getMyWeatherSet();&/font&&/p&&p style=&color: rgb(51, 51, 51); line-height: 26&&&font face=&宋体& size=&3&&& && & updateWeatherInfoView(R.id.weather_0, ws.getMyCurrentCondition());
& && & updateWeatherInfoView(R.id.weather_1, ws.getMyForecastConditions().get(0));
& && & updateWeatherInfoView(R.id.weather_2, ws.getMyForecastConditions().get(1));
& && & updateWeatherInfoView(R.id.weather_3, ws.getMyForecastConditions().get(2));
& && & updateWeatherInfoView(R.id.weather_4, ws.getMyForecastConditions().get(3));
& && &}catch (Exception e){
& && & Log.e(&CityWeather&, e.toString());
& && &}
& &&&}
& & }&/font&&/p&&p style=&color: rgb(51, 51, 51); line-height: 26&&&font face=&宋体& size=&3&&& & package com.yarin.android.CityW
& & public class ConstData{
& &&&public static final String queryString=&&a href=&/ig/api?hl=zh-cn&weather& style=&text-decoration:&&/ig/api?hl=zh-cn&weather&/a&=,,,&;
& &&&public static final String queryString_intput=&&a href=&/ig/api?hl=zh_cn&weather& style=&text-decoration:&&/ig/api?hl=zh_cn&weather&/a&=&;
& &&&public static final String [] cityCode ={
& && &&279998&,//北京
& && &&470001&,//上海
& && &&169998&,//天津
& && &&480003&,//重庆
& && &&150001&,//唐山
& && &&419998&,//石家庄
& && &&629997&,//大连
& && &&769996&,//哈尔滨
& && &&349998&,//海口
& && &&220001&,//长春
& && &&870002&,//长沙
& && &&019996&,//成都
& && &&279998&,//福州
& && &&319999&,//广州
& && &&720001&,//贵阳
& && &&720001&,//贵阳
& && &&169998&,//杭州
& && &&230003&,//合肥
& && &&680000&,//呼和浩特
& && &&980003&,//济南
& && &&680000&,//昆明
& && &&32050&,//拉萨
& && &&879997&,//兰州
& && &&919998&,//南昌
& && &&800003&,//南京
& && &&349998&,//南宁
& && &&330001&,//青岛
& && &&099998&,//深圳
& && &&430000&,//沈阳
& && &&550003&,//太原
& && &&20002&,//乌鲁木齐
& && &&129997&,//武汉
& && &&930000&,//西安
& && &&769996&,//西宁
& && &&080001&,//厦门
& && &&150001&,//徐州
& && &&220001&,//银川
& && &&650001&//郑州& && && && &&&
& &&&};
& &&&public static final String [] city ={
& && &&北京&,//
& && &&上海&,//
& && &&天津&,//
& && &&重庆&,//
& && &&唐山&,//
& && &&石家庄&,//
& && &&大连&,//
& && &&哈尔滨&,//
& && &&海口&,//
& && &&长春&,//
& && &&长沙&,//
& && &&成都&,//
& && &&福州&,//
& && &&广州&,//
& && &&贵阳&,//
& && &&杭州&,//
& && &&合肥&,//
& && &&呼和浩特&,//
& && &&济南&,//
& && &&昆明&,//
& && &&拉萨&,//
& && &&兰州&,//
& && &&南昌&,//
& && &&南京&,//
& && &&南宁&,//
& && &&青岛&,//
& && &&深圳&,//
& && &&沈阳&,//
& && &&太原&,//
& && &&乌鲁木齐&,//
& && &&武汉&,//
& && &&西安&,//
& && &&西宁&,//
& && &&厦门&,//
& && &&徐州&,//
& && &&银川&,//
& && &&郑州&//
& &&&};
& & }
& &&/font&&/p&&/font&复制代码
& & AndridManifest.xml
&&&font face=&宋体& size=&3&&&font face=&宋体& size=&3&&&&&?xml version=&1.0& encoding=&utf-8&?&
& &&&&manifest
& && &xmlns:android=&&a href=&/apk/res/android& style=&text-decoration:&&/apk/res/android&/a&&
& && &package=&com.yarin.android.CityWeather&
& && &android:versionCode=&1&
& && &android:versionName=&1.0&&
& && &&application
& && & android:icon=&@drawable/icon&
& && & android:label=&@string/app_name&&
& && & &activity
& && &&&android:name=&.CityWeather&
& && &&&android:label=&@string/app_name&&
& && &&&&intent-filter&
& && && &&action android:name=&android.intent.action.MAIN& /&
& && && &&category android:name=&android.intent.category.LAUNCHER& /&
& && &&&&/intent-filter&
& && & &/activity&
& && &&/application&
& && &&uses-permission android:name=&android.permission.INTERNET&&&/uses-permission&//因为我们信息时通过网络获得的所有需要在此注册访问网络的权限
& && &&uses-sdk android:minSdkVersion=&5& /&
& &&&&/manifest&&/font&&/font&复制代码
TA的每日心情擦汗 14:56签到天数: 4 天[LV.2]偶尔看看I
不错哦哦~
Beijing Aptech Beida Jade Bird Information Technology Co.,Ltd
北大青鸟IT教育 北京阿博泰克北大青鸟信息技术有限公司 版权所有

我要回帖

更多关于 新西兰11月天气 的文章

 

随机推荐