Webview Searching?

Ksmith1192

Member
Licensed User
Hi Guys,

Does anyone know if you can use an edittext to search throughout a webview? Here is my code, it is really simple.
Thanks! :sign0104:
 

Attachments

  • Const.zip
    167.3 KB · Views: 179

Erel

Administrator
Staff member
Licensed User
You can use reflection to call findAll method. This method will highlight the results and return the number of items found.
B4X:
Sub Globals
   Dim WebView1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   WebView1.LoadUrl("http://www.basic4ppc.com")
End Sub

Sub Activity_Click
   Log(FindAll(WebView1, "Basic4android"))
End Sub

Sub FindAll (w As WebView, s As String) As Int
   Dim r As Reflector
   r.Target = w
   Return r.RunMethod2("findAll", s, "java.lang.String")
End Sub
 
Upvote 0

Mahares

Expert
Licensed User
This method will highlight the results and return the number of items found
Using Erel's code in the previous post, it does not highlight any text. It logs the number of occurences of the search, but there is no text highlighting. What else is missing?
Thank you
 
Upvote 0

Mahares

Expert
Licensed User
@Erel: You are absolutely correct. I ran it on two OS 4.03 devices and both did not highlight the search. But then, after you mentioned it, I ran it on a an OS4.2 device and it did highlight the search.
Thank you
 
Upvote 0

Ksmith1192

Member
Licensed User
Erel, I tried adding in the code, but I keep getting java errors when I run the AVD emulator. Is there something I missed? Here is my program.
 

Attachments

  • Const.zip
    167.4 KB · Views: 162
Upvote 0
Top