`
lizhuang
  • 浏览: 888275 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

asynchronous http request xml范例

 
阅读更多
client.post(context, API_URL, httpEntity, CONTENT_TYPE, new AsyncHttpResponseHandler(){
    @Override
    public void onSuccess(String response) {
        ListView entries;
        ArrayList<HashMap<String, String>> invoiceList = new ArrayList<HashMap<String, String>>();
        XmlParser xmlParser = new XmlParser();
        Document doc = xmlParser.getDomElement(response);
        NodeList nl = doc.getElementsByTagName("INVOICE");
        for (int i = 0; i < nl.getLength(); i++) {
            Element e = (Element) nl.item(i);
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("amount", NumFormat.currency(xmlParser.getValue(e, ("TOTAL"))) + xmlParser.getValue(e, "CURRENCY_CODE"));
            map.put("company", xmlParser.getValue(e, "CUSTOMER_ID"));
            //map.put("company", xmlParser.getValue(e, "INVOICE_ID"));
            map.put("payment", xmlParser.getValue(e, "PAID_DATE"));
            map.put("due", xmlParser.getValue(e, "DUE_DATE"));
            invoiceList.add(map);
        }
        InvoiceAdapter adapter = new InvoiceAdapter(getApplicationContext(), invoiceList, customFont);
        entries = (ListView) findViewById(R.id.list_outgoing_invoices);
        entries.setAdapter(adapter);
    }

    @Override
    public void onFailure(Throwable e, String response) {
        Hint.showHint(context, getString(R.string.error_receive_data), Hint.LONG);
    }
});
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics