I set HTML mode to my TextView so in my text some String is blue or green. Now I need replace "old" to "new" without losing blue and green color. If use from textview.setText(textview.getText().toString().repaceAll("old", "new"))
, we lose its style and color! In fact I need code that preserves the styles. Or I need replace String in Spanned without losing its style and color.
- I need replace String in Spanned obj
- I need set Spanned obj to my TextView. But I don't know any way.
old string is
oldstr
and new string isnewstr