WEB开发网
开发学院手机开发Android 开发 Android 之 webView 加载 javascropt 阅读

Android 之 webView 加载 javascropt

 2010-04-14 18:02:00 来源:WEB开发网   
核心提示:首先在layout文件夹下的xml中 加入Java代码1. < WebView2. android:id="@+id/wv1"3. android:layout_width="fill_parent"4. android:layout_height="fill_p

首先在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");

1 2 3 4 5  下一页

Tags:Android webView 加载

编辑录入:coldstar [复制链接] [打 印]
赞助商链接