tags:

views:

26

answers:

1

Hello In my android application i am using a webview to display apage of contents . What i require is like if the user longpress on a word then that particular word should be highlighted and should be highlighted even if the user reloads the app again.

Is there any way that i can get this done in android.

Please forward your valuable suggestions.

Thanks in advance:)

A: 

Putting it in a WebView is what will make this tricky, if it were just a regular view I would say extend TextView and implement onLongClickListener for it as well. Not sure how to squeeze this into an existing webview though :/

schwiz
even for textview onlongclick listener how can i highlght only that word and save the format so that even on reloading the highlight remain the same
Remmyabhavan
make only words you want to be highlighted your special class and everything else be a normal text view. Or get fancy with all the different text measuring stuff in the Paint class in your view and try to find what word they are touching with the XY coords of the long press.
schwiz
also dig through the sourcecode of `TextView` maybe they are already keeping track of where different words are.
schwiz
Also look into linkify, maybe you can add the word pressed to your custom regex to highlight it http://developer.android.com/reference/android/text/util/Linkify.html
schwiz
It depends on how the words are.. but I'm thinking if you have like multiple textviews with one word each, in the OnLongClickListener, just have it set background to like yellow, but if its just one.. I'm not sure, sorry, not sure how to make only a spot colored. If you're able to figure out how to make a specific place highlighted, like if you have a string and the background is only yellow behind one char, you can put all your words into an arraylist each new input seperated by the spaces, then set that word as a yellow background..
Samuel