Make a word in TextVew clickable

69 views Asked by At

I am developing a dictionary app. When I search some keyword it will display its description. Now I want if any keyword (of my database) is used in describing other keyword I want that describing keyword to be clickable (and coloured or/and underlined). So that if I click on that word search will be made using the clicked keyword and will display the result. I am using SQLitedatabase to create database. Please see the attached picture.

Sample picture: Sample picture

1

There are 1 answers

3
Anoop On

You can use spans to style your text shown on a textview. There is a span subclass called ClickableSpan, which will be able to serve your needs. Takea a look at ClickableSpan also there is another span class called UnderlineSpan which can be used for putting underline for the specified character range. Hope this helps