D Deleted member 103 Guest Jan 9, 2020 #1 Hi, I've been looking for a solution all afternoon and can't find it, so I'm asking here with a new thread. I would like to load an Html file in which images are also displayed. The file loading works without problems like this: B4X: Copy WebView1.LoadHtml(File.ReadString(File.DirAssets, "file.html")) but it shows no pictures. The line that shows the picture in B4a is: src="file:///android_asset/image.png" The line that shows the picture in B4i is: src="image.png" But how should the line that the image should display in B4j: src="???????? image.png" I also found this thread, but I don't get along.
Hi, I've been looking for a solution all afternoon and can't find it, so I'm asking here with a new thread. I would like to load an Html file in which images are also displayed. The file loading works without problems like this: B4X: Copy WebView1.LoadHtml(File.ReadString(File.DirAssets, "file.html")) but it shows no pictures. The line that shows the picture in B4a is: src="file:///android_asset/image.png" The line that shows the picture in B4i is: src="image.png" But how should the line that the image should display in B4j: src="???????? image.png" I also found this thread, but I don't get along.
DonManfred Expert Licensed User Longtime User Jan 9, 2020 #2 Filippo said: I also found this thread, but I don't get along. Click to expand... As for b4j you need to create the fileuri... B4X: Copy File.GetUri(File.DirAssets, FileName) Have you tried to define the correct uri in your html file? Upvote 0
Filippo said: I also found this thread, but I don't get along. Click to expand... As for b4j you need to create the fileuri... B4X: Copy File.GetUri(File.DirAssets, FileName) Have you tried to define the correct uri in your html file?
D Deleted member 103 Guest Jan 9, 2020 #3 DonManfred said: As for b4j you need to create the fileuri... B4X: Copy File.GetUri(File.DirAssets, FileName) Have you tried to define the correct uri in your html file? Click to expand... Unfortunately I do not understand how that should define. Upvote 0
DonManfred said: As for b4j you need to create the fileuri... B4X: Copy File.GetUri(File.DirAssets, FileName) Have you tried to define the correct uri in your html file? Click to expand... Unfortunately I do not understand how that should define.
DonManfred Expert Licensed User Longtime User Jan 9, 2020 #4 run this code for any image in assets to get the uri. Log it. Adapt the img src Tag (in the htmlfile) to be a valid uri like the one you got. Upvote 0
run this code for any image in assets to get the uri. Log it. Adapt the img src Tag (in the htmlfile) to be a valid uri like the one you got.
DonManfred Expert Licensed User Longtime User Jan 9, 2020 #5 Example Attachments wvimg.zip wvimg.zip 257 KB · Views: 404 Upvote 0
D Deleted member 103 Guest Jan 9, 2020 #6 Thanks Manfred, but that is not practical. The Html file should work in every installation folder. Upvote 0
DonManfred Expert Licensed User Longtime User Jan 9, 2020 #7 You REALLY should have mentioned it in the first post You started the thread about a htmlfile and an image in assets. NOWHERE else... Thank you for sending me the wrong track! Upvote 0
You REALLY should have mentioned it in the first post You started the thread about a htmlfile and an image in assets. NOWHERE else... Thank you for sending me the wrong track!
D Deleted member 103 Guest Jan 9, 2020 #8 I'm sorry, I thought my question was understandable. In any case, my solution now looks like this: The line that shows the picture in B4j is: src="######/image.png" and my code is: B4X: Copy Dim str As String = File.ReadString(File.DirAssets, "file.html") Dim DirAssets As String = File.GetUri(File.DirAssets, "file.html") str = str.Replace("######", DirAssets.Replace("file.html","")) WebView1.LoadHtml(str) Upvote 0
I'm sorry, I thought my question was understandable. In any case, my solution now looks like this: The line that shows the picture in B4j is: src="######/image.png" and my code is: B4X: Copy Dim str As String = File.ReadString(File.DirAssets, "file.html") Dim DirAssets As String = File.GetUri(File.DirAssets, "file.html") str = str.Replace("######", DirAssets.Replace("file.html","")) WebView1.LoadHtml(str)