I tried to use a click on a button in a webview to launch other activity but it's not working.
I followed this example of this post:
http://www.b4x.com/android/forum/threads/link-in-un-webview.31660/
This is my code:
My project is attached.
Thank you in advance to anyone who can help me.
I followed this example of this post:
http://www.b4x.com/android/forum/threads/link-in-un-webview.31660/
This is my code:
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private wvTur As WebView
Dim NameBar, AddressBar As String
Dim MyWebViewExtras As WebViewExtras
End Sub
Sub Activity_Create(FirstTime As Boolean)
NameBar = "Gondola Restaurant"
AddressBar = "Philadelphia Street"
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("webpage1")
wvTur.JavaScriptEnabled=True
MyWebViewExtras.addJavascriptInterface(wvTur, "B4A")
wvTur.LoadHtml("<html><body><h3>" & NameBar & "</h3><p>Address:<br/><strong>" & AddressBar & "</strong></p> " & "<p>Telephone:<br/><strong>5555-7777</strong></p>"& "<button onclick='B4A.CallSub('MyB4ASub', true)'"&">Show Activity</button>"&"</body></html>")
wvTur.ZoomEnabled = False
End Sub
Sub MyB4ASub
' this Sub will be called by the onclick event of the image
StartActivity(Activity2)
End Sub
My project is attached.
Thank you in advance to anyone who can help me.
Attachments
Last edited: