我是我的应用程序中的新手我希望设置动态文本& webview中的图像。动态文本已完成,但从资源文件夹获取图像时出现问题。我想在Webview中设置右上角。 这是我的代码
ImgName = "a" + pro_id + "_th";
int res = this.getResources().getIdentifier("com.example.app:drawable/" + ImgName,null, null);
webView = (WebView) findViewById(R.id.activityDDetail_Discription_webView);
webView.setBackgroundColor(Color.TRANSPARENT);
String disc = Model.get_discription();
String html1 = "<div style=\"text-align: justify; margin: 10px 0px;\"><div style=\"float: right; margin: 0px 3px 1px 10px;\"><font color = \"ffffff\" face = \"HelveticaNeue-Light\" size = \"3.0\">"+ discription()+ "</font></span> </div>";
webView.loadData(html1, "text/html", "UTF-8");
html1 = String.format(html1, ImgName);
final String mime = "text/html";
final String encoding = "UTF-8";
答案 0 :(得分:0)
我正在使用它,
Using the resource id, the format is:
"android.resource://[package]/[res id]"
Uri path = Uri.parse("android.resource://com.androidbook.samplevideo/" + R.raw.myvideo);
or, using the resource sub directory (type) and resource name (file name without extension), the format is:
"android.resource://[package]/[res type]/[res name]"
Uri path = Uri.parse("android.resource://com.androidbook.samplevideo/raw/myvideo")