我希望 webview 显示资源中的图片和数据库中的 html 代码,但只有数据库中的 html 代码可以正常工作。
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\" />";