Android Question Include image in WebView using LoadHTML

wl

Well-Known Member
Licensed User
Longtime User
Hello,

I have a WebView control in my application that displays tekst using LoadHTML.

I would now like to include a image inside the HTML (the file resides in the File.DirAssets folder of the appliction).


I tried to include something like "<img src='file://" & File.DirAssets & "/someimage.jpg'/>"
but this does not seem to work.

Thanks for any advice ...
 
You must install the icon in job folder.
Dim TargetDir As String
TargetDir = RutaDBCorrecta

If File.Exists(TargetDir,"bullet_green.ico") = False Then
File.Copy(File.DirAssets,"bullet_green.ico",TargetDir,"bullet_green.ico")
End If


and inclue the ref in html:

For i = 0 To cur.ColumnCount - 1
sb.Append("<td>")

If i = 0 Then
LinkImg="<img src='file://" & RutaDBCorrecta & "/bullet_green.ico'/>"
Else
LinkImg=""
End If
NombreCampo = "com"
NombreCampo = cur.GetColumnName(i)

If Clickable Then
sb.Append("<a href='http://").Append(i).Append(".")
sb.Append(row)
sb.Append("." & NombreCampo & "'>" & LinkImg).Append(cur.GetString2(i)).Append( "</a>")
Else
sb.Append(cur.GetString2(i))
End If
sb.Append("</td>")
Next


------------
function required in
Sub RutaDBCorrecta() As String
Dim TargetDir As String
If File.ExternalWritable Then TargetDir = File.DirDefaultExternal Else TargetDir = File.DirInternal

Return TargetDir
End Sub


this works for me. (this code is a idea, no copy and paste).
 
Upvote 0
Back
Top