![](/uploads/image/0831.jpg)
最近由于谷歌天气预报接口出现了一些小问题,没办法,只能重新写一下国家气象局天气预报接口JSON完全解析,程序包括了所有的地点,所以有些复杂 1.首先准备好要解析的json数据,方便以后写程序解析的时候,直接进行分析。如下
[html] view plaincopyprint?
1.{ "weatherinfo":
2. { <!-- 基本信息 -->
3. "city":"北京",
4. "city_en":"beijing",
5. "date_y":"2012年8月14日",
6. "date":"",
7. "week":"星期二",
8. "fchh":"18",
黑山谷景区电话9. "cityid":"101010100",
10.<!-- 从今天开始到第六天的每天的天气情况,这里的温度是摄氏温度 --> 11. "temp1":"19℃~31℃",
12. "temp2":"21℃~31℃",
13. "temp3":"22℃~28℃",
14. "temp4":"20℃~28℃",
15. "temp5":"21℃~29℃",
16. "temp6":"22℃~31℃",
17.<!-- 从今天开始到第六天的每天的天气情况,这里的温度是华氏温度 -->
18. "tempF1":"66.2℉~87.8℉",
19. "tempF2":"69.8℉~87.8℉",
20. "tempF3":"71.6℉~82.4℉",
21. "tempF4":"68℉~82.4℉",
22. "tempF5":"69.8℉~84.2℉",
23. "tempF6":"71.6℉~87.8℉",
25. "weather1":"阵雨转晴",
重庆旅游必去景点有哪些26. "weather2":"晴",
27. "weather3":"多云转雷阵雨",
28. "weather4":"雷阵雨",
29. "weather5":"多云转阴",
30. "weather6":"雷阵雨",
31.<!-- 天气描述图片序号 -->
32. "img1":"3",
33. "img2":"0",
34. "img3":"0",
35. "img4":"99",
36. "img5":"1",
37. "img6":"4",
38. "img7":"4",
39. "img8":"99",
40. "img9":"1",
41. "img10":"2",
42. "img11":"4",
43. "img12":"99",
44. "img_single":"0",
45.<!-- 图片名称 -->
46. "img_title1":"阵雨",
47. "img_title2":"晴",
48. "img_title3":"晴",
49. "img_title4":"晴",
50. "img_title5":"多云",
51. "img_title6":"雷阵雨",
52. "img_title7":"雷阵雨",
53. "img_title8":"雷阵雨",
54. "img_title9":"多云",
55. "img_title10":"阴",
56. "img_title11":"雷阵雨",
57. "img_title12":"雷阵雨",
58. "img_title_single":"晴",
59.<!-- 风速描述 -->
60. "wind1":"微风",
61. "wind2":"微风",
62. "wind3":"微风",
63. "wind4":"微风",
成都武侯祠需要门票吗
64. "wind5":"微风",
65. "wind6":"微风",
66. "fx1":"微风",
67. "fx2":"微风",
68.<!-- 风速级别描述 -->
69. "fl1":"小于3级",
70. "fl2":"小于3级",
71. "fl3":"小于3级",
72. "fl4":"小于3级",
73. "fl5":"小于3级",
74. "fl6":"小于3级",
75.<!-- 今天穿衣指数 -->
76. "index":"炎热",
77. "index_d":"天气炎热,建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。
",
78.<!-- 48小时穿衣指数 -->
79. "index48":"炎热",
80. "index48_d":"天气炎热,建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。
",
81.<!-- 紫外线及48小时紫外线 -->
82. "index_uv":"很强",
83. "index48_uv":"强",
84.<!-- 洗车 -->
85. "index_xc":"较不宜",
86.<!-- 旅游 -->
赤道几内亚87. "index_tr":"适宜",
88.<!-- 舒适指数 -->
89. "index_co":"较不舒适",
90. "st1":"31",
91. "st2":"17",
92. "st3":"31",
93. "st4":"22",
94. "st5":"27",
95. "st6":"22",
96.<!-- 晨练 -->
97. "index_cl":"适宜",
98.<!-- 晾晒 -->
99. "index_ls":"极适宜",
100.<!-- 过敏 -->
101. "index_ag":"易发"
102. }
103.}
2.先让大家看看我的布局,让大家知道我的这个程序是干什么呢。如下图 3.布局代码如下
[html] view plaincopyprint?
1.<?xml version="1.0"encoding="utf-8"?>
2.<LinearLayout xmlns:android="schemas.android/apk/res/android"
3.android:layout_width="fill_parent"
4.android:layout_height="fill_parent"
5.android:orientation="vertical">
6.
7.<LinearLayout
8.android:layout_width="match_parent"
卫星地图高清2019
9.android:layout_height="wrap_content">
10.
11.<Spinner
12.android:id="@+id/spinner1"
13.android:layout_width="wrap_content"
14.android:layout_height="wrap_content"
15.android:layout_weight="1"/>
16.
17.<Spinner
18.android:id="@+id/spinner2"
19.android:layout_width="wrap_content"
去青岛旅游大概要多少钱
20.android:layout_height="wrap_content"
21.android:layout_weight="1"/>
22.
23.<Button
24.android:id="@+id/button1"
25.android:layout_width="wrap_content"
26.android:layout_height="wrap_content"
27.android:layout_weight="1"
28.android:text="省市查询"/>
29.</LinearLayout>
30.
31.<LinearLayout
32.android:layout_width="match_parent"
33.android:layout_height="wrap_content">
34.
35.<EditText
36.android:id="@+id/editText1"
37.android:layout_width="wrap_content"
38.android:layout_height="wrap_content"
39.android:layout_weight="1"
40.android:ems="10"
41.android:text="西安">
42.
43.<requestFocus/>
44.</EditText>
45.
46.<Button
47.android:id="@+id/button2"
48.android:layout_width="wrap_content"
49.android:layout_height="wrap_content"
50.android:layout_weight="1"
51.android:text="特殊市县查询"/>
52.</LinearLayout>
53.
54.<LinearLayout
55.android:layout_width="match_parent"
56.android:layout_height="wrap_content">
57.
58.<ImageView
59.android:id="@+id/imageView1"
60.android:layout_width="wrap_content"
61.android:layout_height="wrap_content"
62.android:src="@drawable/ic_launcher"/>
63.
64.<ImageView
65.android:id="@+id/imageView2"
66.android:layout_width="wrap_content"
67.android:layout_height="wrap_content"
68.android:src="@drawable/ic_launcher"/>
69.
70.<TextView
71.android:id="@+id/textView1"
72.android:layout_width="wrap_content"
73.android:layout_height="wrap_content"
74.android:text="Large Text"/>
75.</LinearLayout>
76.
77.<LinearLayout
78.android:layout_width="match_parent"
79.android:layout_height="wrap_content">
80.
81.<ImageView
82.android:id="@+id/imageView3"
83.android:layout_width="wrap_content"
84.android:layout_height="wrap_content"
85.android:src="@drawable/ic_launcher"/>
86.
87.<ImageView
88.android:id="@+id/imageView4"
89.android:layout_width="wrap_content"
90.android:layout_height="wrap_content"
91.android:src="@drawable/ic_launcher"/>
92.
93.<TextView
94.android:id="@+id/textView2"
95.android:layout_width="wrap_content"
96.android:layout_height="wrap_content"
97.android:text="Large Text"/>
98.</LinearLayout>
99.
100.<LinearLayout
101.android:layout_width="match_parent"