0

我有以下方法可以从android调用。我已将其编写如下,但控件未进入 javascript。请让我知道是否有人有任何解决方案。

String resp = javascript:httpservicesuccess("{\"code\":\"200\",\"requestID\":\"1000\",\"body\":\"{\"units\":{\"temperature\":\"C\",\"speed\":\"km\/h\",\"distance\":\"km\",\"pressure\":\"mb\"},\"location\":{\"location_id\":\"ITXX0024\",\"city\":\"Como\",\"state_abbreviation\":\"*\",\"country_abbreviation\":\"IT\",\"elevation\":935,\"latitude\":45.81000000000000,\"longitude\":9.08000000000000},\"wind\":{\"speed\":5.00000000000000,\"direction\":\"S\"},\"atmosphere\":{\"humidity\":\"47\",\"visibility\":9.99000000000000,\"pressure\":1016.00000000000000,\"rising\":\"steady\"},\"url\":\"http:\/\/weather.yahoo.com\/forecast\/ITXX0024.html\",\"logo\":\"http:\/\/l.yimg.com\/a\/i\/us\/nt\/ma\/ma_nws-we_1.gif\",\"astronomy\":{\"sunrise\":\"06:47\",\"sunset\":\"18:22\"},\"condition\":{\"text\":\"Fair\",\"code\":\"34\",\"image\":\"http:\/\/l.yimg.com\/a\/i\/us\/we\/52\/34.gif\",\"temperature\":10.00000000000000},\"forecast\":[{\"day\":\"Today\",\"condition\":\"Sunny\",\"high_temperature\":13.00000000000000,\"low_temperature\":3.00000000000000},{\"day\":\"Tomorrow\",\"condition\":\"Partly Cloudy\",\"high_temperature\":14.00000000000000,\"low_temperature\":5.00000000000000}]}\",\"headers\":{"Date":"Mon, 23 Apr 2012 03:50:41 GMT","Cache-Control":"public, max-age=1800","Expires":"Mon, 23 Apr 2012 04:20:41 GMT","Connection":"close","Transfer-Encoding":"chunked","Content-Type":"application/json;charset=UTF-8"}}")  
webView.loadUrl(resp);

谢谢斯内哈
_

4

1 回答 1

0

你错了。以这种方式使用它。它不是 URL,而是 HTML 字符串。

webview.loadData(resp, "text/html", null);

编辑 - 使用正确的格式(我不确定 text/html 是否正确)。但这就是您加载数据的方式。

于 2012-04-23T05:11:40.500 回答