2013-05-30 27 views
2

我擁有一個configuration.xml文件,我擁有所有的(是的,你猜對了!)..配置字符串和值和東西。如何在string.xml文件中添加「 - 」,但沒有轉義

其中一個值是一個字符串,它是一個OAuth客戶端ID,它有一個連字符..

<string name="server_clientid">5467656-blahblahblah.apps.googleusercontent.com</string> 

現在,我得到了警告信息..

Replace "-" with an "en dash" character (–, &#8211;) ? 

確定不夠公平,但如果我用這個逃脫,那麼當我在應用程序中獲取它時,客戶端ID是無效的。我不能使用&#8211;基本上。我如何解決這個問題?

+0

這是警告..你可以使用這個字符串.. –

+0

是什麼阻止你在閱讀UUID時解析連字符? – adrianp

+1

[如何在string.xml文件中添加「 - 」]的副本(http://stackoverflow.com/questions/10578551/how-to-put-a-in-string-xml-file)。你會在那裏得到你的答案。 –

回答

7

您在

<![CDATA[ ]]> 

從解析內容停止解析器包裹你的價值觀。例如。

<string name="server_clientid"><![CDATA[ 5467656-blahblahblah.apps.googleusercontent.com ]]></string> 
+1

我很確定''進入'string'標籤。 – Cornholio

+1

@Cornholio你是對的,更新 – dKen

6

您還可以抑制lint警告(因爲破折號是不是在印刷上下文中使用哪個是假的):

<resources xmlns:tools="http://schemas.android.com/tools"> 

... 

<string name="server_clientid" tools:ignore="TypographyDashes">5467656-blahblahblah.apps.googleusercontent.com</string> 
+0

Wowww!大!.. –

0

的 「N破折號」( - ,–)和「m破折號」( - ,—) 字符用於範圍(n破折號)和破折號(m破折號)。使用 這些而不是簡單的連字符可以使文本更易於閱讀,並且您的應用程序看起來更精美。

替換較小的 「-」 有更大的 「-」。你已準備好出發。

相關問題