【发布时间】:2011-05-18 15:53:10
【问题描述】:
我的 Android 应用上有一个页面,该页面将使用以下代码显示 html 文件的内容 -
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.intro);
WebView wv = (WebView) findViewById(R.id.WebView01);
try {
InputStream fin;
fin = getAssets().open("Preface.html");
byte[] buffer = new byte[fin.available()];
fin.read(buffer);
fin.close();
wv.loadData(new String(buffer), "text/html", "UTF-8");
} catch (IOException e) {
e.printStackTrace();
}
}
代码运行正常,但网页视图中没有显示内容,我做错了什么?
【问题讨论】:
标签: android android-layout android-webview