Android Question WebView code shows blank screen

aklisiewicz

Active Member
Licensed User
Longtime User
I'm trying this code and get a blank screen instead. any ideas ?

B4X:
Sub Activity_Create(FirstTime As Boolean)
    SQL1.Initialize(Main.dbFileDir, Main.dbFileName, True)
    Activity.Title = "Document Content"
    Activity.LoadLayout("DocumentFormView_LT")
    WebView1.Initialize("WebView1")
    WebView1.LoadHtml("<html><body>Hello world!</body></html>")
    ProgressDialogShow("Loading " &DocUrl)
End Sub

Art
 

aklisiewicz

Active Member
Licensed User
Longtime User
SOLVED
never mind, it was WebView.Initialize() statement causing problem. I removed it and it works.
This code was for testing, but now I replaced fixed HTML with the HTML which supposed to stored in TXT field in a table. I want to grab html code and place it in LoadUrl call so I can display a html page.


B4X:
Sub Activity_Create(FirstTime As Boolean)
    SQL1.Initialize(Main.dbFileDir, Main.dbFileName, True)
    Activity.Title = "Document Content"
    Activity.LoadLayout("DocumentFormView_LT")
    'DocUrl = "file:///android_asset/" & DocumentList.selectedFile
    DocSource = SQL1.ExecQuery("SELECT HtmlSource FROM mDOCUMENTS WHERE ID="&DocumentList.SelectedRecord)
    WebView1.LoadHtml(DocSource)
    'WebView1.LoadHtml("<html><body>Hello World<br></body></html>")
    ProgressDialogShow("Loading " &DocUrl)
End Sub
this code instead of html page displays :

android.database.sqlite.SQLiteCursor@412a363

any ideas ?
Arthur


PS>
here is the html code sored in database:
-------------------
B4X:
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>UserHtml_0005</title>
</head>
<body>
this is a used HTML document NR 4<br>
<br>
here is the image<br>
<br>
<img style="width: 960px; height: 960px;" alt="pituitary gland"
src="file:///D:/DATA/DEV/PROJECTS_B4A/EDBQ_MOBILE/Files/n32.jpg"><br>
</body>
</html>
 
Last edited:
Upvote 0

aklisiewicz

Active Member
Licensed User
Longtime User
SOLVED
never mind I forgat to read the cursor. for those who might have wondered ehre is the proper code to read an HTML source code and present it in a WebView:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    SQL1.Initialize(Main.dbFileDir, Main.dbFileName, True)
    Activity.LoadLayout("DocumentFormView_LT")
    Activity.Title = "Document Content"
    Cursor = SQL1.ExecQuery("SELECT ID, HtmlSource FROM mDOCUMENTS WHERE ID="&DocumentList.SelectedRecord)
        For i = 0 To Cursor.RowCount - 1
            Cursor.Position = i
            DocSource = Cursor.GetString("HtmlSource") 
        Next
    WebView1.LoadHtml(DocSource)
    ProgressDialogShow("Loading " &DocUrl)
End Sub

I still need to parse the image location...
 
Upvote 0
Top