Android Question Indentifying WebView Triggering _PageFinished Event

DawningTruth

Active Member
Licensed User
My activity has more than one webview. How do I determine which webview triggered the Page Finished event?

B4X:
Sub myWebview_PageFinished(Url As String)
    Log("myWebview Attributes")
    Log(Url) 'This is the right url
    Log(myWebview) 'This is the wrong webview
End Sub

It looks like the standard approach only supplies the url. I want to also get the webview that triggered the event.

How do I do this?
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
OK - so presumably you are initializing them both with the same event name - ie: .Initialize("myWebview")? If so, just use Sender to get the correct one:

B4X:
Sub myWebview_PageFinished(Url As String)
    Private thisWebView as WebView = Sender
    
    Log("myWebview Attributes")
    Log(Url) 'This is the right url
    Log(thisWebView) 'This is the webview that fired the PageFinished event.
End Sub

- Colin.
 
Upvote 0

DawningTruth

Active Member
Licensed User
OK - so presumably you are initializing them both with the same event name - ie: .Initialize("myWebview")? If so, just use Sender to get the correct one:

B4X:
Sub myWebview_PageFinished(Url As String)
    Private thisWebView as WebView = Sender
   
    Log("myWebview Attributes")
    Log(Url) 'This is the right url
    Log(thisWebView) 'This is the webview that fired the PageFinished event.
End Sub

- Colin.
Thx Colin. Worked like a charm :)
 
Upvote 0
Top