0

How to keep words clickable separately in one TextView. For example, If have a big story and when you click a word in it should show the meaning of that word.

I used to split string but could not make words clickable separately.

Thanks in advance.

Ramlal S
  • 1,573
  • 1
  • 14
  • 34

1 Answers1

0

Use Spannable String.Here I am making terms of use clickable, something like this

SpannableString spannableString = new SpannableString("I have read and agreed to the 
Terms of Use & Privacy Policy");

 ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(View widget) {
            //opening terms of use screen
        }
    };


String termOfUse = "Terms of Use"; 
spannableString.setSpan(clickableSpan, 30, 30 + termOfUse.length(), 0);
Roshaan Farrukh
  • 399
  • 3
  • 10