当前位置: 代码迷 >> XML/SOAP >> asynchronous http request xml实例
  详细解决方案

asynchronous http request xml实例

热度:665   发布时间:2014-01-12 00:03:16.0
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);
    }
});
  相关解决方案