0

I apologize for that horrible title but I want to be accurate.

I have ScrollView in that LinearView and in that I dynamically create multiple rows filled with sentences by TextView. I set different collors created using SpannableText but I don't know ho to make every single word of that TextView responding the way I want - pop dialog question that will contain this word and ask me what I want to do with it. I want to move it to EditText in next fragment.. only that..

Please, what kind of magic would be the most suitable for this event? And maybe a kick with little example on one sentence.

Dalton
  • 347
  • 3
  • 15
  • 2
    Use [ClickableSpan](http://developer.android.com/reference/android/text/style/ClickableSpan.html) to the words that you want to response to click event. – Wenhui Jul 28 '14 at 23:39
  • Thank you, I found one superb solution in answers of "Related" questions. This question is [here](http://stackoverflow.com/questions/8612652/select-a-word-on-a-tap-in-textview-edittext). One thing I don't know is how to make text again red or .. normal like it was before adding that onClick event.. – Dalton Jul 29 '14 at 18:41

1 Answers1

0

There are much more you can do with Spannable, this blog post has everything about Spannable, and it should be able to help you.

If you don't want to read the whole blog, than here is the short answer.

Use ForegroundColorSpan.

SpannableString ss = new SpannableString("Color text");
ForegroundColorSpan span = new ForegroundColorSpan(Color.RED);
ss.setSpan(span, 0, ss.length(), 0);
Wenhui
  • 648
  • 4
  • 13