Android Question search in webview, old code not working

AnandGupta

Expert
Licensed User
Longtime User
I wanted to give search in my webview report.
Searched the Forum for it and found below,


Since it is very old thread and codes given are also very old for B4X version, so made a new project and used the codes.
Runs OK, but the second 'click' for 2nd search for 'strom' does not show the highlighted text. Though it is there in debug log.
Tried both in release and debug in B4A 10.0.

I must be missing some code to invalidate / refresh the webview, though .invalidate also did not work.
Attached the project. Need help on it or idea of different code which works on today's version.

Regards,

Anand
 

Attachments

  • test.zip
    10.1 KB · Views: 104

drgottjr

Expert
Licensed User
Longtime User
do me a favor: run the thing first, then look at the code. i approach it a totally different way from you. i wasn't comfortable with the way you did it, and you may feel the same about my method. i couldn't see why what you did didn't work, so after a couple hours, i decided to go with what i would normally use. if you have any questions, you can pm. as you know, we're not supposed to linger over a thread beyond one or two posts.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Code with Msgbox = broken code.

There are many other things that can be improved.

Use XUI.FileUri to create the url instead of line #72.
The codes are as it is from the example given in the thread

And is very old and I only made it run-able in new version of B4A
Will make the changes, but am only interested in making it work as expected.

Regards,

Anand
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Thanks drgottjr for the changes I checked it.

But it is now highlight all found text
I am trying to get search, search next (and if possible search previous but not required now)
and the webview jumping to focus the searched text position.
The original code is for the above logic but is not working.

I think some webview cache problem here, but could not fix it.

(I thought it is better to clarify here than pm, sorry if I made mistake)

Regards,

Anand
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
my understanding was that the user would enter a search word and tap the button. the app would then find all the matches for that word and, starting with the first match, jump to the next match when the user tapped the hypertext link. unless i am mistaken, that's what my suggestion does. (i also disabled the button after the first click since it appears to start the search all over again. i would think that the user wouldn't want to start all over until she had seen all the matches.) going forwards or backwards is not difficult to implement (at least not based on the example i provided).

in any case, i'm sorry i misunderstood the purpose of your app, and, of course, that i offered no solution to why your code doesn't do what you want it to.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
in any case, i'm sorry i misunderstood the purpose of your app, and, of course, that i offered no solution to why your code doesn't do what you want it to.
No sorry between friends
You have given your valuable time and that counts much more than the solution.

The logic is what I already have in similar desktop app, so wanted it to do in Android. The code does it, if you check the log, the anchor moves to next word, but the webview does not refresh with the new temp.htm.

Anyway I will keep it in hold now till I find something similar.

Regards,

Anand
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…