0

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

Hexfire
  • 5,945
  • 8
  • 32
  • 42
Neo
  • 7
  • 5

1 Answers1

0

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

Anoop
  • 993
  • 6
  • 16
  • Thank for your response. That's ok, but I want only those words clickable which exist in my database as keyword. For that what should I do? – Neo Dec 21 '17 at 03:50
  • format those words using ClickableSpan, It has a onClicked(View) callback on the span. So only the ClickableSpan formatted words will be clickable – Anoop Dec 21 '17 at 03:55
  • My database is created when my app is starting for the first time (i.e. during installation) and reading from a .txt file through a bufferedReader. Would you please show me some sample, I don't have any idea how to do that. – Neo Dec 21 '17 at 04:13