close

今天看到同事有報出以下錯誤

error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
error: Unexpected end tag string

 

這是一個在 string.xml 中設定字串時要注意的一件事

平時我們用 String.format() 時

會設定 %s 、%f 等佔位符號,以方便我們帶入參數

 

但在 string.xml 中要注意,若有兩個以上,則會報此錯誤

正確的寫法是 %「第幾個」$「型態」

如下:

<string name="cardless_daily_limit">
以千元為單位,單日單次上限%1$s\n今日已提款「%2$s」</string>
<string name="cardless_account_balance">
可用餘額 %s</string>

 

 

 

 

 

 

 

 


arrow
arrow

    顏澤偉 發表在 痞客邦 留言(0) 人氣()