-1

我试图在我的 android 程序中设置一个按钮,当按下该按钮时,它会从 web api 获取一些信息并在我的屏幕上显示结果。

这是完成所有工作的代码,但我需要将它放在我的 android 页面中:

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<script type="text/javascript">
<!--
function get_temp(){
var url = "http://api.wunderground.com/api/00000000003/conditions/q/';
    url+=$('#lat').val()+','+$('#lon').val()+' .json?callback=?';
    $('#log').html($('#log').html()+url);
    $.getJSON(url, function(data) {
        var temp = data['current_observation']['temp_c'];
        $('#out').html($('#shoedata').html()+temp+'<br>');
    });
 }
 //-->
</script>
Latitude <input type="text" name="name" id="lat" />
Longitude <input type="text" name="name" id="lon" />
<input value="Get temperatura" type="button" onclick="get_temp()"/>
<div id='out'>Current temperature: </div>
<div id="log">Log: </div>
</body>
</html>

我怎样才能做到这一点?在android中编写js代码我应该遵循哪些步骤?jquery和jsonp有什么不同吗?谢谢!

4

1 回答 1

0

嗨朋友使用下面给出的链接。

http://developer.android.com/reference/android/webkit/WebView.html

JSON,XML连接到Android的Web api?

希望这些对您有所帮助。

于 2013-09-03T10:15:24.480 回答