watesoft Active Member Licensed User Longtime User Dec 23, 2017 #1 Code: Copy Sub Activity_Click 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 I load a long html text in webview ,find and highlight all the keyword with above code, I want to see them one by one,but when I use below code,error occurred:"NoSuchMethodException: findNext [class java.lang.String]", Where is my fault? Code: Copy Sub FindNext_Click FindNext(WebView1, "Basic4android") End Sub Sub FindNext (w As WebView, s As String) As Int Dim r As Reflector r.Target = w Return r.RunMethod2("findNext", s, "java.lang.String") End Sub
Code: Copy Sub Activity_Click 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 I load a long html text in webview ,find and highlight all the keyword with above code, I want to see them one by one,but when I use below code,error occurred:"NoSuchMethodException: findNext [class java.lang.String]", Where is my fault? Code: Copy Sub FindNext_Click FindNext(WebView1, "Basic4android") End Sub Sub FindNext (w As WebView, s As String) As Int Dim r As Reflector r.Target = w Return r.RunMethod2("findNext", s, "java.lang.String") End Sub
Erel B4X founder Staff member Licensed User Longtime User Dec 24, 2017 #2 Try this: 1. Find all: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findAllAsync", Array(s)) 2. Next match: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findNext", Array(True)) Requires Android 4.1+ (api 16) Upvote 0
Try this: 1. Find all: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findAllAsync", Array(s)) 2. Next match: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findNext", Array(True)) Requires Android 4.1+ (api 16)
watesoft Active Member Licensed User Longtime User Dec 25, 2017 #3 Erel said: Try this: 1. Find all: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findAllAsync", Array(s)) 2. Next match: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findNext", Array(True)) Requires Android 4.1+ (api 16) Click to expand... Thank you Erel,I tried the method you provided, the result is very good. Upvote 0
Erel said: Try this: 1. Find all: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findAllAsync", Array(s)) 2. Next match: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findNext", Array(True)) Requires Android 4.1+ (api 16) Click to expand... Thank you Erel,I tried the method you provided, the result is very good.
watesoft Active Member Licensed User Longtime User Feb 9, 2018 #4 Erel said: Try this: 1. Find all: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findAllAsync", Array(s)) 2. Next match: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findNext", Array(True)) Requires Android 4.1+ (api 16) Click to expand... Hi Erel, I met another problem,I want to match and highlight multi keywords in webview,like below: Code: Copy Dim SS() as string SS = Array As String("AAA", "BBB", "CCC") Dim i as Int Dim jo As JavaObject = WebView1 for i=0 to SS.length-1 jo.RunMethod("findAllAsync", Array(SS(i))) next Result: only "CCC" is highlighted, why, I want to highlight "AAA" and "BBB" and "CCC". Upvote 0
Erel said: Try this: 1. Find all: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findAllAsync", Array(s)) 2. Next match: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findNext", Array(True)) Requires Android 4.1+ (api 16) Click to expand... Hi Erel, I met another problem,I want to match and highlight multi keywords in webview,like below: Code: Copy Dim SS() as string SS = Array As String("AAA", "BBB", "CCC") Dim i as Int Dim jo As JavaObject = WebView1 for i=0 to SS.length-1 jo.RunMethod("findAllAsync", Array(SS(i))) next Result: only "CCC" is highlighted, why, I want to highlight "AAA" and "BBB" and "CCC".
Erel B4X founder Staff member Licensed User Longtime User Feb 9, 2018 #5 Try it like this: Code: Copy Dim SS() as string = Array As String("AAA", "BBB", "CCC") Dim jo As JavaObject = WebView1 for Each s As String In SS jo.RunMethod("findAllAsync", Array(s)) Sleep(200) next Upvote 0
Try it like this: Code: Copy Dim SS() as string = Array As String("AAA", "BBB", "CCC") Dim jo As JavaObject = WebView1 for Each s As String In SS jo.RunMethod("findAllAsync", Array(s)) Sleep(200) next
watesoft Active Member Licensed User Longtime User Feb 10, 2018 #6 Erel said: Try it like this: Code: Copy Dim SS() as string = Array As String("AAA", "BBB", "CCC") Dim jo As JavaObject = WebView1 for Each s As String In SS jo.RunMethod("findAllAsync", Array(s)) Sleep(200) next Click to expand... Thanks Erel,let me try the code. Upvote 0
Erel said: Try it like this: Code: Copy Dim SS() as string = Array As String("AAA", "BBB", "CCC") Dim jo As JavaObject = WebView1 for Each s As String In SS jo.RunMethod("findAllAsync", Array(s)) Sleep(200) next Click to expand... Thanks Erel,let me try the code.
bernardR Member Licensed User Longtime User Jan 8, 2020 #7 Hello, I have try the code of Erel (#5, Feb 9, 2018) for match and highlight multi keywords in webview. It don't works. Only "CCC" is highlighted. Did you find a solution ? Thanks Last edited: Jan 8, 2020 Upvote 0
Hello, I have try the code of Erel (#5, Feb 9, 2018) for match and highlight multi keywords in webview. It don't works. Only "CCC" is highlighted. Did you find a solution ? Thanks
watesoft Active Member Licensed User Longtime User Jan 9, 2020 #8 Sorry,I tried my best for a long time ,but failed. Upvote 0
DonManfred Expert Licensed User Longtime User Jan 9, 2020 #9 I guess only ONE highlighting can be active at a time. https://developer.android.com/reference/android/webkit/WebView Finds all instances of find on the page and highlights them, asynchronously. Notifies any registered FindListener. Successive calls to this will cancel any pending searches. Click to expand... So, calling this method will remove the last highlight... Upvote 0
I guess only ONE highlighting can be active at a time. https://developer.android.com/reference/android/webkit/WebView Finds all instances of find on the page and highlights them, asynchronously. Notifies any registered FindListener. Successive calls to this will cancel any pending searches. Click to expand... So, calling this method will remove the last highlight...
hayk Member Mar 13, 2023 #10 Erel said: Try this: 1. Find all: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findAllAsync", Array(s)) 2. Next match: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findNext", Array(True)) Requires Android 4.1+ (api 16) Click to expand... When online PDF file is opened in webview, search matched text is not highlighted. Is there way to fix that? Upvote 0
Erel said: Try this: 1. Find all: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findAllAsync", Array(s)) 2. Next match: Code: Copy Dim jo As JavaObject = WebView1 jo.RunMethod("findNext", Array(True)) Requires Android 4.1+ (api 16) Click to expand... When online PDF file is opened in webview, search matched text is not highlighted. Is there way to fix that?