开发者

can't replace string with image in android webview html

开发者 https://www.devze.com 2023-02-18 20:30 出处:网络
Tiker is a string which have name and value both + and - i want to change that with images... bt using this on + and - will hide bt image don\'t show...

Tiker is a string which have name and value both + and - i want to change that with images... bt using this on + and - will hide bt image don't show...

so help to find my solution.

WebView mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);

tiker = tiker.replaceAll("\\+","<img src=drawable\"up.开发者_如何学运维PNG\">");
tiker = tiker.replaceAll("\\-","<img src=drawable\"down.PNG\">");

String summary = "<html><body><MARQUEE>"+tiker+"</MARQUEE></body></html>";
mWebView.loadData(summary, "text/html", "utf-8");


You cannot access images in 'drawable' directory from a WebView. You must put the images in 'assets' directory and access them with 'file:///android_asset/...'

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号