Siten
Siten

Reputation: 4533

can't replace string with image in android webview html

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");

Upvotes: 0

Views: 952

Answers (1)

ognian
ognian

Reputation: 11541

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/...'

Upvotes: 1

Related Questions