也許是一個(gè)簡(jiǎn)單的問(wèn)題 - 我需要幫助從我的 strings.xml 中設(shè)置多個(gè)字符串。 mytext.setText(resources.getString(R.string.history_text1+R.string.history_text2));所以我的意思是我需要通過(guò)一個(gè) setText 將 2 個(gè)不同的文本作為一個(gè)文本。但是使用這種語(yǔ)法我有一個(gè)錯(cuò)誤:android.content.res.Resources$NotFoundException: String resource ID #0xfe1e0079
2 回答
寶慕林4294392
TA貢獻(xiàn)2021條經(jīng)驗(yàn) 獲得超8個(gè)贊
嘗試這個(gè):
mytext.setText(resources.getString(R.string.history_text1) + resources.getString(R.string.history_text2))
叮當(dāng)貓咪
TA貢獻(xiàn)1776條經(jīng)驗(yàn) 獲得超12個(gè)贊
值:R.string.history_text1和R.string.history_text2
是引用資源中實(shí)際字符串的整數(shù)。
通過(guò)添加它們,您會(huì)得到另一個(gè)不引用任何內(nèi)容的整數(shù),因此您會(huì)得到:
Resources$NotFoundException
如果要連接 2 個(gè)字符串值:
String value = resources.getString(R.string.history_text1) + resources.getString(R.string.history_text2) mytext.setText(value);
添加回答
舉報(bào)
0/150
提交
取消
