Android Question Local web page not showing <img>

anOparator

Active Member
Licensed User
Longtime User
Am having major problem loading a local web page, IMG not showing:
1. I can load background images onto Webview:
B4X:
  WebV.LoadHtml("<html><body background='file:///android_asset/image.jpg'></body></html>")
2. I can load webpage onto Webview but the pictures don't show:
B4X:
Sub Process_Globals
  Dim wbpage As String
End Sub

Sub Globals   
  Private wv1 As WebView
  Private Button1 As Button
End Sub

Sub Button1_Click
  wbpage = File.ReadString(File.DirAssets, "mywebpage.htm")
  wv1.LoadHTML(wbpage)
End Sub
I have read:
https://www.b4x.com/android/forum/threads/animated-gif-not-running-on-webview.33781/#content
https://www.b4x.com/android/forum/threads/webview-load-file-from-file-dirinternal.19058/#content
https://www.b4x.com/android/forum/threads/adding-an-animated-gif-to-your-app.29872/
and
https://www.b4x.com/android/forum/threads/webview-tutorial.24343/ ' post #20 - remote page shows img, local page doesn't
https://www.b4x.com/android/forum/threads/webview-tutorial.24343/page-2

How to modify the HTML and point to the image in the assets directory?
 

Attachments

  • noImg.zip
    7.5 KB · Views: 105

sorex

Expert
Licensed User
Longtime User
it works, I tried it 2 years ago but I don't recall how it was exactly.

try to use ./ ../ or something like it to get to the right path. (it won't recognize file:///)
 
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
Oops, so much for speed reading, the answer was in:
https://www.b4x.com/android/forum/threads/adding-an-animated-gif-to-your-app.29872/
B4X:
Sub Globals
    Private wv1 As WebView
    Private Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("imgyes")
End Sub
Sub Button1_Click
wv1.LoadURL("file:///android_asset/awebpage.htm")   ' THIS path works on my Samsung , loads web page w/imgage
End Sub

' File not used (warning #15) if .html and .jpg not added to projects File tab. Can warning be avoided?

Three cheers for B4A
 
Upvote 0
Top