I'm getting a wall of plain HTML text from the server and need to render it in my application, but that's not all.
I also need to detect clicks on specific phrases within the text. The phrases are defined by two numbers: word count where the phrase starts and word count where it ends (e.g. from word 10 to word 15).
My intuition says that I could probably instrument the HTML with links or some JavaScript according to phrases spec and then listen for clicks on these links. However, I'm not sure how to achieve this kind of functionality in Android.
In addition, I also need to be able to programmatically observe and manipulate the scrolling position within the shown HTML text. For instance, I'll need to understand when a specific phrase is scrolled off the screen.
I guess I have three closely related questions:
- Which View should I use to achieve the above functionality (
TextView
,WebView
, other)? - How can I listen for clicks on specific parts of HTML?
- How can I observe and manipulate the scrolling position?
Thanks