0

I want to use split method to find special characters and then remove them and replace with images. I used html formatted texts in CDATA tag in Strings.xml file and send it to a Textview . How can I determine that special characters in that text (html formatted) in my java code and replace images and show those images between texts. Thanks.

1 Answers1

0

The simplest way would be to search within the String using the indexOf method. Something like this:

String yourString = "lorem(ipsum)";
String [] charsToReplace = new Array ('(', ')');

for (String thisChar : charsToReplace) {
    while (yourString.indexOf(thisChar) > -1) {
        // do something with ImageSpan or something
    }
}

Not sure if this is the best way though...

Shade
  • 9,936
  • 5
  • 60
  • 85