【发布时间】:2011-09-06 11:39:23
【问题描述】:
我是 Android 新手。
我想在安卓模拟器中显示 HTML 页面。我将“test1.html”和“test2.html”文件放在“assets”文件夹中,并使用以下代码设法在 Android 中显示“test1.html”文件。
package com.example.helloandroid;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.os.Bundle;
public class Test extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webview = new WebView(this);
setContentView(webview);
try {
InputStream fin = getAssets().open("test1.html");
byte[] buffer = new byte[fin.available()];
fin.read(buffer);
fin.close();
webview.loadData(new String(buffer), "text/html", "UTF-8");
} catch (IOException e) {
e.printStackTrace();
}
}
}
现在我想单击“test1.html”文件中的按钮或链接并打开“test2.html”文件。如何链接这两个 HTML 页面?
提前致谢。
【问题讨论】: