Android 2.2上WebView中的绑定事件
我无法使用WebView将点击和滑动事件绑定到我的应用程序中,该WebView具有简单的示例代码,可以在浏览器中正常工作。我用的是JQuery手机。有什么想法吗Android 2.2上WebView中的绑定事件,android,jquery-mobile,android-webview,Android,Jquery Mobile,Android Webview,我无法使用WebView将点击和滑动事件绑定到我的应用程序中,该WebView具有简单的示例代码,可以在浏览器中正常工作。我用的是JQuery手机。有什么想法吗 <!DOCTYPE html> <html> <head> <title>jQuery Mobile Events</title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/j
<!DOCTYPE html>
<html>
<head>
<title>jQuery Mobile Events</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile- 1.0a3.min.css" />
<script src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
<script type="text/javascript">
$( function() {
$('body').bind( 'taphold', function( e ) {
alert( 'You tapped and held!' );
e.stopImmediatePropagation();
return false;
} );
$('body').bind( 'swipe', function( e ) {
alert( 'You swiped!' );
e.stopImmediatePropagation();
return false;
} );
} );
</script>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header">
<h1>jQuery Mobile Events</h1>
</div>
<div data-role="content">
<p>Try:</p>
<ul>
<li>Tapping and holding</li>
<li>Swiping</li>
</ul>
</div>
</div>
</body>
</html>
下面是Javascript界面:
import java.io.IOException;
import android.content.Context;
import android.widget.Toast;
public class JavaScriptInterface {
Context mContext;
AudioRecord audiorecord;
/** Instantiate the interface and set the context */
JavaScriptInterface(Context c) {
mContext = c;
}
/** Show a toast from the web page */
public void showToast(String toast) {
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
}
// OnSwipe() here?
}
所以我可能应该在这里添加方法,当检测到滑动时,应该在JQuery中用Android.onswip()调用它?为什么上面的JQuery移动代码不能用于导航?WebView不应该像web浏览器一样工作吗
提示:jQuery有一个比1.5(1.5.1和1.5.2)更新的版本
import java.io.IOException;
import android.content.Context;
import android.widget.Toast;
public class JavaScriptInterface {
Context mContext;
AudioRecord audiorecord;
/** Instantiate the interface and set the context */
JavaScriptInterface(Context c) {
mContext = c;
}
/** Show a toast from the web page */
public void showToast(String toast) {
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
}
// OnSwipe() here?
}