Sub Globals
Private btnFind As Button
Private EditText1 As EditText
Private WebView1 As WebView
Private FindListener As Object
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("webfind")
WebView1.LoadUrl("http://www.planalto.gov.br/ccivil_03/Constituicao/ConstituicaoCompilado.htm")
Dim jo As JavaObject = WebView1
FindListener = jo.CreateEventFromUI("android.webkit.WebView.FindListener", "FindListener", Null)
jo.RunMethod("setFindListener", Array(FindListener))
End Sub
Sub btnFind_Click
Dim word As String = EditText1.Text
Dim jo As JavaObject = WebView1
jo.RunMethod("findAllAsync", Array(word))
Do While True
Wait For FindListener_Event (MethodName As String, Args() As Object)
Dim ActiveMatchOrdinal As Int = Args(0) 'ignore
Dim NumberOfMatches As Int = Args(1)
Dim IsDoneCounting As Boolean = Args(2)
If IsDoneCounting Then Exit
Loop
Log("Total matches: " & NumberOfMatches)
End Sub