Android Question Webview - while page not finished - simple question [solved]

trepdas

Active Member
Licensed User
Longtime User
Hello good b4x people,

I want to enable a button only when webview has finished loading a page.

but when webview is working - to disable that button.

I already made the button enable when page finished with WebView1_PageFinished

But how do I disable the button if page is still loading or started to load a new page ?

I want this button to be visible only when webview has finished loading a page, but disable it again if webview started to load a new url...

TIA
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
button.visible = [true|false], as needed. if it's not visible, it doesn't mater whether it's enabled or not.
 
Upvote 0

trepdas

Active Member
Licensed User
Longtime User
Thank you for your response but I was not asking how to enable/disable the button but how to check if webview is working or not...
 
Upvote 0

roumei

Active Member
Licensed User
You can try to use the OverrideURL event for this:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    Button1.Enabled = False
    Button1.Text = "Loading"
    WebView1.LoadUrl("https://www.google.com")
    
End Sub

Private Sub WebView1_OverrideUrl (Url As String) As Boolean
    Log("OverrideUrl: " & Url)
    Button1.Enabled = False
    Button1.Text = "Loading"
    Return False
End Sub

Private Sub WebView1_PageFinished (Url As String)
    Log("PageFinished: " & Url)
    Button1.Enabled = True
    Button1.Text = "Ready"
End Sub
 
Upvote 0
Top