Escape "" in text in TextView

I have a textView and I insert the string s as text and in which I have some double quote characters. How can I avoid these characters.

+7
source share
2 answers

Double quotes with backslash will not work in the XML layout. You should use HTML code (quot), for example:

<TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="Here goes my &quot;escaped&quot; text!" /> 

In the above code, a TextView will be displayed containing:

Here is my runaway text!

XML has 5 of these purported entities :

 &quot; " &amp; & &apos; ' &lt; < &gt; > 
+14
source

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 that string to a TextView:

 myString.replace("\"", ""); 
+3
source

All Articles