Hi, I have a styled Spannable String, which gets append()ed to other
Spannables. Rather then restyle it each time, I was hoping to style it
once and reuse it over and over. It seems there isn't possible because
the styles get removed when append()ing to other
SpannableStringBuilders after the initial append. Is there a way to
work around this? I've attached some example code that shows the
problem:
TextView t = (TextView) findViewById(R.id.tv);
final SpannableStringBuilder sp = new SpannableStringBuilder("foobar
\n");
sp.setSpan(new ForegroundColorSpan(Color.RED), 0, sp.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
final SpannableStringBuilder sp2 = new SpannableStringBuilder("foo ");
sp2.append(sp);
t.append(sp2); //ok, foobar is red
final SpannableStringBuilder sp3 = new SpannableStringBuilder("bar ");
sp3.append(sp);
t.append(sp3); //foobar is no longer red
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---