Android 【山西違章查詢實現4】(解析網頁源碼然後ListView顯示出來)--- 將解析出來的資料放到ListView中

來源:互聯網
上載者:User

標籤:

這次更簡單了。

List<Map<String, String>> data = new ArrayList<Map<String, String>>(); Map<String, String> map = new HashMap<String, String>();

然後將mr.group(i)中的資料拿出來放進去

protected void onPostExecute(String result)        {            List<Map<String, String>> data = new ArrayList<Map<String, String>>();            Pattern p = Pattern.compile("這裡是Regex");            Matcher m = p.matcher(result);            while(m.find()){                MatchResult mr = m.toMatchResult();                          Map<String, String> map = new HashMap<String, String>();                map.put("time",(mr.group(1)).trim()+" "+mr.group(2).trim());                map.put("address",mr.group(3).trim());                map.put("action","("+mr.group(4).trim()+")"+mr.group(5).trim());                map.put("money","扣"+mr.group(6).trim()+"分 罰"+mr.group(7).trim()+"元");                map.put("chuli",(mr.group(12).trim()));                data.add(map);                }      //自訂adapter
          SimpleAdapter adapter = new SimpleAdapter(“這裡是樣式了”); 
          item_lv.setAdapter(adapter);

}

結果可以實現了。

 

弄上一些美化的UI,然後加上資料庫操作(儲存車牌和車架號),一個基本的山西違章查詢就ok了。

Android 【山西違章查詢實現4】(解析網頁源碼然後ListView顯示出來)--- 將解析出來的資料放到ListView中

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.