Answer the question
In order to leave comments, you need to log in
A few unrelated issues with WebView, html resources and ListView?
There are several problems. It is not necessary to read everything and answer everything at once, I made subheadings to the problems so that you can immediately see what we are dealing with. In general, to business. There are two activities. On the first one - a ListView, on the second WebView, which loads html files from the project's raw resources. The web element works under this simple code:
WebView webView;
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
String text = readRawTextFile(context, getResources().getIdentifier(resName, "raw", "mypackagename"));
webView.loadDataWithBaseURL("file:///android_asset/", text, "html", "utf-8", null);
<a href="file:///android_asset/pic1.jpg"><img src="file:///android_asset/pic1.jpg" height="300dp"></a>
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Check if the key event was the Back button and if there's history
if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) {
myWebView.goBack();
return true;
}
// If it wasn't the Back key or there's no web page history, bubble up to the default
// system behavior (probably exit the activity)
return super.onKeyDown(keyCode, event);
}
<body background="file:///android_res/drawable/background_html.jpg" bgproperties="fixed"></body>
<a href="file:///android_res/raw/file4.html">Ссылка на другой html-файл из ресурсов</a>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question