2011-06-21 11 views
68

Próbuję wyświetlić niektóre słowa w cudzysłów, w widoku tekstowym w w pliku xml. Ale to nie działa. Pls mi pomóc.Jak wyświetlić cudzysłowy (") Symbol w TextView?

<TextView 
    style="@style/TextStyle" 
    android:text="message "quote string 1" and "quote string 2" end message" 
    android:id="@+id/lblAboutPara3" 
    android:autoLink="web"/>  

Każdy zna rozwiązanie tego .............

Odpowiedz

125

W strings.xml można po prostu uciec znaki specjalne (np cudzysłowach) z odwrotnym ukośnikiem:

"message \"quote string 1\" and \"quote string 2\" end message" 

Ale w widoku xml (np. layout.xml), trzeba użyć encje HTML (jak &quot;)

"message &quot;quote string 1&quot; and &quot;quote string 2&quot; end message" 

więcej, odwiedź http://developer.android.com/guide/topics/resources/string-resource.html

+0

sama odpowiedź jak wyżej – Shah

+0

nie działa na mnie – moatist

+0

to nie działa –

11

korzystanie escape characters. Aby wyświetlić podwójne użycie cudzysłowu \"

Twój kod będzie

android:text="message \"quote string 1\" and "quote string 2\" end message" 
+0

Tak, to piszę – Shah

8

Spróbuj

<TextView 
style="@style/TextStyle" 
android:text='message \"quote string 1\" and \"quote string 2\" end message' 
android:id="@+id/lblAboutPara3" 
android:autoLink="web"/> 
3
<TextView 
style="@style/TextStyle" 
android:text='message "quote string 1" and "quote string 2" end message' 
android:id="@+id/lblAboutPara3" 
android:autoLink="web"/> 
60

Zastosowanie &quot; symbol, aby rozwiązać ten problem hardcode :)

android:text="message &quot;quote string 1&quot;" 
+0

pracuję dla mnie Dziękuję –

+1

To musi być poprawne i jeśli chcesz ** "** symbol w pliku układu bez użycia ** string.xml **. –

+1

Jesteś HERO :) –

4
TextView.setText(Html.fromHtml("&ldquo; " + "YOUR TEXT" + " &rdquo;")); 
Powiązane problemy