title: Android ClickableSpan not changing style onclick
body: <p>I have a TextView in which all words are individually clickable. I want to begin with every word unstyled. Upon clicking a word, the word should become and remain underlined. I am able to clear the default underline, but nothing happens upon click. (I am capturing and even processing the click, but I cannot get the Span style to change).</p>
  
  <p>The relevant code is below. Thanks in advance for the help.</p>
  
  <p>Custom ClickableSpan:</p>
  
  <pre><code>class WordSpan extends ClickableSpan {
    private TextPaint textpaint;
    public boolean clicked = false;
  
    @Override
    public void updateDrawState(TextPaint ds) {
      textpaint = ds;
      ds.setUnderlineText(false);
  
      if (clicked)
        ds.setUnderlineText(true);
    }
  
    @Override
    public void onClick(View v) {}
  
    public void setClicked(boolean c) {
      clicked = c;
      updateDrawState(textpaint);
    }
  }
  </code></pre>
  
  <p>From onCreate() I am parsing a txt file and adding each word to a TextView. Within this parsing loop I have the following code:</p>
  
  <pre><code>  SpannableString ss = new SpannableString(word.toString());
  
    WordSpan clickableSpan = new WordSpan() {
      @Override
      public void onClick(View view) {
      setClicked(true);
      view.invalidate();
      }};
  
    ss.setSpan(clickableSpan, 0, word.toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  
    tvText.append(ss);
    tvText.append(" ");
  }
  
  tvText.setMovementMethod(LinkMovementMethod.getInstance());
  </code></pre>