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.
Asked
Active
Viewed 36 times
0
-
What do you mean by "special characters"? – Shade Oct 25 '16 at 11:29
-
I want to determine where to add images in the texts so I thought to use special characters like ( and ) to find the location of where I want to show an image – Android_Dev Oct 25 '16 at 11:31
-
This is what you are looking for http://stackoverflow.com/a/21250752/4288782 – natario Oct 25 '16 at 11:40
-
Thank you for reply – Android_Dev Oct 26 '16 at 11:59
1 Answers
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