我按照说明在我的应用程序中显示Web视图,工作正常,
但现在我需要显示一个内部的html文件,
所以我的第一个问题,
可以将我的html文件夹拖放到eclipse中我的应用程序的"res"文件夹中吗?
如果是这样,我该如何查询位置:
水库\ HTML\index.html在
所以我可以在我的应用程序中显示index.html?
在我的网址中要更改什么,使用URI?
mWebView.loadUrl( "http://www.google.com");
这条路是唯一改变的吗?
谢谢!
删除index.html文件在assets文件夹中.然后,在其中创建一个layout并WebView在其中将其设置为这样的布局Activity
setContentView(R.layout.html_layout); //load the layout XML file
WebView mbrowser = (WebView) findViewById(R.id.mwebview); //get the WebView from the layout XML
mbrowser.loadUrl("file:///android_asset/index.html"); //set the HTML
Run Code Online (Sandbox Code Playgroud)
html_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mwebview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3663 次 |
| 最近记录: |