T
T
TriKrista2015-09-17 19:44:59
Android
TriKrista, 2015-09-17 19:44:59

QML loading html code in webview?

There is html code (htmlCode), resources referenced by the code are located at "assets:/res"
code and resources are added to the WebView in this way: But the resources (images) are not displayed. How to fix it? Ps The program must work on Android
WebView.loadHtml(htmlCode, "assets:/res")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lazard105, 2015-09-24
@TriKrista

Links to images from assets should look like file:///android_asset/YourAssetFilename
Example :

String sHtmlTemplate = "<html><head></head><body><img src=\"file:///android_asset/img/mybadge.png\"></body></html>";
webView.loadDataWithBaseURL(null, sHtmlTemplate, "text/html", "utf-8",null);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question