TextView에서 큰 따옴표 ( ") 기호를 표시하는 방법은 무엇입니까?


96

xml 파일의 텍스트보기에서 일부 단어를 큰 따옴표로 표시하려고합니다. 그러나 작동하지 않습니다. Pls 도와주세요.

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

누구든지 이것에 대한 해결책을 알고 있습니다 .............

답변:


190

에서 strings.xml, 당신은 단순히 백 슬래시 특수 문자 (예 : 큰 따옴표)를 탈출 할 수 있습니다 :

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

그러나 뷰 xml (예 :) layout.xml에서는 HTML 문자 엔티티 (예 :)를 사용해야합니다 &quot;.

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

자세한 내용은 http://developer.android.com/guide/topics/resources/string-resource.html을 방문 하십시오.


6
그것은 <= "double_quote"문자열 이름> \ "</ 문자열>하지만 layout.xml에 strings.xml의 작동
타일러 데이비스

OP가 strings.xml이 아닌 "xml 파일의 텍스트보기에서 큰 따옴표"에 대해 구체적으로 묻기 때문에이 대답은 올바르지 않습니다.
Patrick

69

&quot;이 하드 코드 문제를 해결 하려면 기호를 사용하십시오. :)

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

1
당신이 원하는 경우에 올바른 ANS해야한다 " 레이아웃 파일에서 심볼을 사용하지 않고 string.xml를 .
Jaydipsinh 자라

1
이것을 사용할 수 없다는 사실 strings.xml은 큰 문제입니다.
Mike Baxter

14

를 사용하십시오 escape characters. 큰 따옴표 사용을 표시하려면\"

귀하의 코드는

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

10

시도하십시오

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



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

1

작은 따옴표를 사용하여 메시지를 래핑하고 문자열 안에 원하는만큼 큰 따옴표를 사용할 수 있습니다.

android:text='message "quote string 1" and "quote string 2" end message'

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.