当前位置:   article > 正文

《Android 应用 之路》 天气预报(一)_android第一次进入应用时,显示北京的天气

android第一次进入应用时,显示北京的天气

###Android天气预报客户端###

####设计思路####

  1. 欢迎界面,版本号,应用名 + 数据后台加载(所有城市的信息获取)
  2. 数据加载完成后跳转到显示界面,显示所有查询到的城市的天气信息
  3. 欢迎界面和天气显示界面分别为单独的Activity
  4. Activity数据传递使用Bundle
  5. 网络请求采用Google原始的Volley包
  6. 后台数据请求采用异步AsyncTask的方式以及实时的进度条的更新
  7. 天气显示界面采用简单的ListView

####使用的Android内容####

  1. Activity的跳转以及数据的传递
  2. 网络数据请求以及Json数据的解析
  3. Volley的初级使用
  4. ListView的初级使用
  5. AsyncTask的初级使用
  6. ProgressBar的初级使用

####如何获取天气信息####
采用www.weather.com.cn提供给我们的接口
例如请求,北京的天气预报
http://www.weather.com.cn/data/cityinfo/101010100.html
获取的信息
{“weatherinfo”:
{“city”:“北京”,“cityid”:“101010100”,“temp1”:"-2℃",“temp2”:“16℃”,“weather”:“晴”,
“img1”:“n0.gif”,“img2”:“d0.gif”,“ptime”:“18:00”}}
JSon数据格式

支持的城市还是比较多的

    private int[] mCityCodeList = {101010100, 101010300, 101010400, 101010500, 101010600,
            101010700, 101010800, 101010900, 101011000, 101011100, 101011200, 101011300,
            101011400, 101011500, 101011600, 101011700, 101011800, 101011900, 101012000,
            101012100, 101012200, 101010200, 101030100, 101030300, 101030400, 101030500,
            101030600, 101031400, 101030800, 101030900, 101031000, 101031100, 101031200,
            101030200, 101030700, 101020100, 101020300, 101020500, 101020600, 101021300,
            101020800, 101020900, 101021000, 101021100, 101021200, 101020200, 101020700,
            101090101, 101090301, 101090402, 101090501, 101091101, 101090701, 101090801,
            101090901, 101091001, 101090201, 101090601, 101180101, 101180301, 101180401,
            101180501, 101180601, 101180701, 101180801, 101180901, 101181001, 101181101,
            101181201, 101181301, 101181401, 101181501, 101181601, 101181701, 101181801,
            101180201, 101220101, 101220301, 101220401, 101220501, 101220601, 101220701,
            101220801, 101220901, 101221001, 101221101, 101221201, 101221301, 101221401,
            101221501, 101221601, 101221701, 101220201, 101210101, 101211101, 101210201,
            101210301, 101210901, 101210501, 101210601, 101210701, 101210801, 101211001,
            101210401, 101040100, 101040300, 101040400, 101040500, 101040600, 101040700,
            101040800, 101040900, 101041000, 101041100, 101041200, 101041300, 101041400,
            101041500, 101041600, 101041700, 101041800, 101041900, 101042000, 101042100,
            101042200, 101042300, 101042400, 101042500, 101042600, 101042700, 101042800,
            101042900, 101043000, 101043100, 101043200, 101043300, 101043400, 101043600,
            101043700, 101040200, 101230101, 101230501, 101230601, 101230701, 101230509,
            101230901, 101230201, 101230301, 101230401, 101230801, 101160101, 101160301,
            101160401, 101160501, 101160601, 101161401, 101160801, 101160901, 101161001,
            101161101, 101161201, 101161301, 101160201, 101160701, 101280101, 101280301,
            101280401, 101280501, 101280601, 101280701, 101280800, 101280901, 101281001,
            101281101, 101281201, 101281301, 101281401, 101281501, 101281601, 101281701,
            101281801, 101281901, 101282001, 101282101, 101280201, 101300101, 101300301,
            101300401, 101300501, 101300601, 101301401, 101300801, 101300901, 101301001,
            101301101, 101301201, 101301301, 101300201, 101300701, 101260101, 101260301,
            101260401, 101260906, 101260601, 101260701, 101260801, 101260201, 101260501,
            101290101, 101290301, 101290601, 101290701, 101290801, 101290901, 101291001,
            101291101, 101291201, 101291301, 101291401, 101291501, 101291601, 101290201,
            101290401, 101290501, 101080101, 101080301, 101080401, 101080501, 101081201,
            101080701, 101080801, 101080901, 101081000, 101081101, 101080201, 101080601,
            101240101, 101240301, 101240401, 101240501, 101241101, 101240701, 101240801,
            101240901, 101241001, 101240201, 101240601, 101200101, 101200501, 101200801,
            101200901, 101201001, 101201101, 101201201, 101201301, 101201401, 101201501,
            101201601, 101201701, 101200201, 101200301, 101200401, 101200601, 101200701,
            101270101, 101270301, 101270401, 101270501, 101270601, 101270701, 101270801,
            101270901, 101271001, 101271101, 101271201, 101271301, 101271401, 101271501,
            101271601, 101271701, 101271801, 101271901, 101272001, 101272101, 101270201,
            101170101, 101170501, 101170401, 101170201, 101170301, 101150101, 101150301,
            101150801, 101150501, 101150601, 101150701, 101150201, 101150401, 101120101,
            101120601, 101120901, 101121001, 101121101, 101121201, 101121301, 101121401,
            101121501, 101121601, 101121701, 101120201, 101120301, 101120401, 101120501,
            101120701, 101120801, 101110101, 101110300, 101110401, 101111001, 101110601,
            101110701, 101110801, 101110901, 101110200, 101110501, 101100101, 101100701,
            101100801, 101100901, 101101001, 101100501, 101100201, 101100301, 101100401,
            101100601, 101101100, 101130101, 101130301, 101130401, 101130501, 101130601,
            101130701, 101130801, 101130901, 101131001, 101131101, 101131201, 101131301,
            101131401, 101131501, 101131601, 101130201, 101140101, 101140301, 101140701,
            101140501, 101140601, 101140201, 101140401, 101340101, 101340201, 101340401,
            101310101, 101310201, 101310202, 101310203, 101310204, 101310205, 101310206,
            101310207, 101310208, 101310209, 101310210, 101310211, 101310212, 101310214,
            101310215, 101310216, 101310217, 101310220, 101310221, 101310222, 101310102,
            101250101, 101250301, 101250401, 101250501, 101250601, 101250700, 101250801,
            101250901, 101251001, 101251101, 101251201, 101251301, 101251401, 101251501,
            101250201, 101190101, 101190301, 101190401, 101190501, 101190601, 101191301,
            101190801, 101190901, 101191001, 101191101, 101191201, 101190201, 101190701,
            101050101, 101050301, 101050401, 101050501, 101050601, 101051301, 101050801,
            101050901, 101051002, 101051101, 101051201, 101050201, 101050701, 101060101,
            101060301, 101060401, 101060901, 101060601, 101060701, 101060801, 101060201,
            101060501, 101070101, 101070301, 101070401, 101070501, 101070601, 101071401,
            101070801, 101070901, 101071001, 101071101, 101071201, 101071301, 101070201,
            101070701};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65

大概就是这么多,具体对应的内容,由于这个简单的天气预报主要是为了练手,直接遍历获取对应的信息,然后使用ListView展示,没有做UI优化。

后面的博客会不断优化,继续更新!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/830437
推荐阅读
相关标签
  

闽ICP备14008679号