Reputation: 14091
I have a textView and I am pasting s string as it's text and in which I have some "double quote characters" How can I escape these characters.
Upvotes: 10
Views: 7725
Reputation: 5969
Backslashing double quotes will not work in a XML layout. You should use the HTML-code (quot), like this:
<TextView android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Here goes my "escaped" text!" />
The above code will display a TextView containing:
Here goes my "escaped" text!
XML has 5 of these predifined entities:
" "
& &
' '
< <
> >
Upvotes: 17
Reputation:
Just use the replace method of the String class: http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#replace(char,%20char)
Use something like this for you String and then pass this String to the TextView:
myString.replace("\"", "");
Upvotes: 3