Webview LoadUrl just blank white box

rlamb2

New Member
Licensed User
Longtime User
Hi all,

I can't for the life of me load a simple url. The WebView just pops up blank.

Here's my code:

Sub Process_Globals
End Sub

Sub Globals
Dim WebView1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
WebView1.Initialize("WebView1")
url = "http://google.com"
WebView1.LoadUrl(url)
End Sub

My end goal is to show a loading gif then once the page is loaded display it.

Any help is greatly appreciated.
 

pluton

Active Member
Licensed User
Longtime User
It is simple and I prefer to dim that url As String like this:

This is basic:
B4X:
Sub Globals
   Dim url As String
   url = "http://google.com"
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("main")
   WebView1.Initialize("WebView1")
   activity.AddView(webview1,0dip, 0dip, 100%x, 100%y)
   WebView1.LoadUrl(url)

End Sub

And this is with Progress Dialog:
B4X:
Sub Globals
   
   Dim WebView1 As WebView
   Dim url As String
   url = "http://google.com"
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("main")
   WebView1.Initialize("WebView1")
   activity.AddView(webview1,0dip, 0dip, 100%x, 100%y)
   WebView1.LoadUrl(url)
   ProgressDialogShow("Loading " &url)
   

End Sub
Sub webview1_PageFinished (StrUrl As String)
   ProgressDialogHide
   ToastMessageShow("Loaded " &StrUrl, False)
End Sub
 
Last edited:
Upvote 0

mjcoon

Well-Known Member
Licensed User
It is simple and I prefer to dim that url As String like this:

This is basic:
B4X:
Sub Globals
   Dim url As String
   url = "http://google.com"
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("main")
   WebView1.Initialize("WebView1")
   activity.AddView(webview1,0dip, 0dip, 100%x, 100%y)
   WebView1.LoadUrl(url)

End Sub

The code gives away that you guys are talking Android but this is the Basic4PPC forum (despite that it says "android" twice)...

"Android Development Forum - Basic4android > Basic4ppc"

Mike.
 
Upvote 0
Top