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
strings.xml <string name = "double_quote"> \ "</ string>では機能しますが、layout.xmlでは機能しません
Tyler Davis

OPは、strings.xmlではなく「xmlファイル内のテキストビュー内の二重引用符」について具体的に尋ねるため、この答えは正しくありません。
Patrick

69

&quot;シンボルを使用してこのハードコードの問題を解決してください:)

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

1
あなたがしたい場合、これは正しいANSでなければならないレイアウトファイル内のシンボルを使用せずにstring.xmlをする
Jaydipsinhザラ

1
これが使えないのstrings.xmlは大きな問題です。
マイクバクスター、2015年

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"/> 




1

一重引用符を使用してメッセージをラップし、文字列内で必要な数の二重引用符を使用できます。

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

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.