0
我希望webview显示来自数据库的资源和html代码的图片,但只有来自数据库的html代码正常工作。如何将资源和html中的图片加载到webview中?
WebView wv = (WebView) findViewById(R.id.wv);
String city = "lichtenstein";
String img = "<img src =\"file://res/drawable/picture.png\" width=\"100\" height=\"100\" />";
String dbHTML = cursor.getString(cursor.getColumnIndex(Database.COLUMN_HTML));
String webdata = "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />" + img + "<br />" + "<span style=\"color:#064896;font-weight:bold;\">" + city + " </span>" + dbHTML;
wv.loadData(webdata, "text/html; charset=UTF-8", null);
我也尝试使用资产文件夹中的图片,但也没有工作。
String img = "<img src =\"file:///android_asset/picture.png\" width=\"100\" height=\"100\" />";
谢谢,它的工作原理。 – kaschey 2013-04-21 18:44:54
我想在webview中设置bg与一些html文本,是否可行? – 2013-10-17 08:10:48