Android WebView JavaScript交互
今天介绍一下,Android中Webview与JavaScript的交互,首先是在布局文件里添加webview控件: [html] view plain copy < WebView android:id= "@+id/webview" android:layout_width= "fill_parent" android:layout_height= "fill_parent" /> 然后是在manifest里添加权限: [html] view plain copy < uses-permission android:name="and 要是webview能够与JavaScript交互,首先需要webview要启用JavaScript: [html] view plain copy WebSettings webSettings = myWebView.getSettings(); webSettings.setJavaScriptEnabled(true); 然后创建JavaScript的接口: [java] view plain copy public class WebAppInterface { Context mContext; /** Instantiate the interface and set the context */ WebAppInterface