Android Question How to get the content from the webview click event?

watesoft

Active Member
Licensed User
Longtime User
I have a html database with sqlite, the records like below:

<p>this is a test<sub>1234</sub>click on it to show commentary </p> ……,many many records!

I use webview to show them,like the pics.

My need is:

Click or touch on the tag of “1234”(only a example),then a pop window will show, the commentary from another database which link to “1234” will show on pop window.

My difficulty:

1. How to raise click event on webview?
2. when click, How to get the content of the tag,for it is the id of commentary record.

I search the forums,but didn't find a good way.
Anyone help me,thank you very much in advance.
 

Attachments

  • Screenshot_2017-03-01-11-53-10.png
    Screenshot_2017-03-01-11-53-10.png
    318 KB · Views: 346
  • Screenshot_2017-03-01-11-52-55.png
    Screenshot_2017-03-01-11-52-55.png
    482.2 KB · Views: 324
Last edited:

watesoft

Active Member
Licensed User
Longtime User
Upvote 0

watesoft

Active Member
Licensed User
Longtime User
Can you modify the stored html?

If so then you can change the clickable terms to links and use the OverrideUrl event to handle the clicks.

<p>this is a test<sub><a href="http://1234">1234</a></sub>click on it to show commentary </p> ……,many many records!

Hi, Erel!
According to your suggestion, I solved the problem soon.
Many thanks
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
In post #4 you added an HREF.
How, in code, would your intercept the HREF http://1234 ?
i.e.
Does this generate an event? If so, what is that event?
I am trying to allow a "click" type of event on an individual <p> line within HTML.
Rusty
 
Upvote 0

watesoft

Active Member
Licensed User
Longtime User
In post #4 you added an HREF.
How, in code, would your intercept the HREF http://1234 ?
i.e.
Does this generate an event? If so, what is that event?
I am trying to allow a "click" type of event on an individual <p> line within HTML.
Rusty

In html string:
B4X:
Zj_Num=" <a href=" & "B" & cur.GetString2(i) & " name=" & "B" & cur.GetString2(i) & " >" & cur.GetString2(i) & ".</a> "

in Sub webview_Event_PageFinished (Url As String):
B4X:
javascript="window.location.hash='" & "B" & Txt_Verse.Text  & "'"
wve.executeJavascript(WV_Main,javascript)
 
Upvote 0
Top