Hello guys I am facing one issue while running interlinked html pages on android amulator. Its just showing index page but links are not working.
package neeru.test;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class TestActivity extends Activity {
/** Called when the activit开发者_如何学JAVAy is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webview = new WebView(this);
setContentView(webview);
try {
InputStream fin = getAssets().open("index.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();
}
}
}
use something like this:
private final static String URL = "file:///android_asset/index.html";
...
mWebView.loadUrl(URL);
then it should work.
精彩评论