我有一个textView,我正在粘贴s字符串作为文本,我有一些“双引号字符”我怎样才能逃避这些字符。
答案 0 :(得分:14)
反斜杠双引号在XML布局中不起作用。您应该使用HTML代码( quot ),如下所示:
<TextView android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Here goes my "escaped" text!" />
上面的代码将显示一个包含以下内容的TextView:
这是我的“转载”文字!
XML有5 of these predifined entities:
" "
& &
' '
< <
> >
答案 1 :(得分:3)
只需使用String类的replace方法:http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#replace(char,%20char)
对你使用类似的东西String然后将这个String传递给TextView:
myString.replace("\"", "");