Android 之 webView 加载 javascropt
2010-04-14 18:02:00 来源:WEB开发网首先在layout文件夹下的xml中 加入
Java代码
1. < WebView
2. android:id="@+id/wv1"
3. android:layout_width="fill_parent"
4. android:layout_height="fill_parent"
5. / >
< WebView
android:id="@+id/wv1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/ >
Java代码
1. public class jsWebDemo extends Activity {
2. /** Called when the activity is first created. */
3. @Override
4. public void onCreate(Bundle savedInstanceState) {
5. super.onCreate(savedInstanceState);
6. setContentView(R.layout.main);
7. WebView wView = (WebView)findViewById(R.id.wv1);
8.
9. ProxyBridge pBridge = new ProxyBridge();
10. wView.addJavascriptInterface(pBridge, "AliansBridge");
11.
12. WebSettings wSet = wView.getSettings();
13. wSet.setJavaScriptEnabled(true);
14.
15. wView.loadUrl("file:///android_asset/index.html");
16.
17. }
18.
19. public class ProxyBridge {
20. public int one () {
21. return 1;
22. }
23. }
24.
25. }
public class jsWebDemo extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView wView = (WebView)findViewById(R.id.wv1);
ProxyBridge pBridge = new ProxyBridge();
wView.addJavascriptInterface(pBridge, "AliansBridge");
WebSettings wSet = wView.getSettings();
wSet.setJavaScriptEnabled(true);
wView.loadUrl("file:///android_asset/index.html");
- ››Android 当修改一些代码时,使用什么编译命令可以最...
- ››Android 如何添加一个apk使模拟器和真机都编译进去...
- ››Android 修改Camera拍照的默认保存路径
- ››Android 如何修改默认输入法
- ››android开发中finish()和System.exit(0)的区别
- ››Android手势识别简单封装类
- ››android中查看项目数字证书的两种方法
- ››Android中获取IMEI码的办法
- ››android 相机报错 setParameters failed
- ››Android重启运用程序的代码
- ››Android为ListView的Item设置不同的布局
- ››android bitmap与base64字符串的互相转换
赞助商链接