[問題] 字串填入問題
請問大家這段程式碼
String strSug = getString(R.string.result);
if (msSex.equals(getString(R.string.sex_male)))
if (iAge < 28)
strSug += getString(R.string.sug_not_hurry);
else if (iAge > 33)
strSug += getString(R.string.sug_get_married);
else
strSug += getString(R.string.sug_find_couple);
else
if (iAge < 25)
strSug += getString(R.string.sug_not_hurry);
else if (iAge > 30)
strSug += getString(R.string.sug_get_married);
else
strSug += getString(R.string.sug_find_couple);
mTxtR.setText(strSug);
其中strSug += getString(R.string.sug_not_hurry);
這個+=在java中不是等於 strSug=strSug+getString(R.string.sug_not_hurry);
這樣子在Android 怎麼會是在StrSug中填入R.string.....中的資料呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.230.249.178
※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1490253315.A.ECD.html
→
03/23 15:21, , 1F
03/23 15:21, 1F
→
03/23 15:46, , 2F
03/23 15:46, 2F
→
03/23 15:59, , 3F
03/23 15:59, 3F
→
03/23 15:59, , 4F
03/23 15:59, 4F
→
03/23 16:26, , 5F
03/23 16:26, 5F
→
03/23 16:26, , 6F
03/23 16:26, 6F
這段code他的作用是把textview顯示文字 if條件
滿足if條件顯示出不同的R.id對應的String
但是 strSug=strSug+"String"
為什麼不直接 StrSug=getString(R.string.sug_not_hurry)
這樣就好
※ 編輯: lihohsin (36.230.249.178), 03/23/2017 16:51:49
→
03/23 17:30, , 7F
03/23 17:30, 7F
→
03/23 17:30, , 8F
03/23 17:30, 8F
→
03/23 17:31, , 9F
03/23 17:31, 9F
推
03/23 17:55, , 10F
03/23 17:55, 10F
→
03/23 17:55, , 11F
03/23 17:55, 11F
→
03/23 17:56, , 12F
03/23 17:56, 12F
→
03/23 17:57, , 13F
03/23 17:57, 13F
→
03/23 17:57, , 14F
03/23 17:57, 14F
→
03/23 17:57, , 15F
03/23 17:57, 15F
→
03/23 17:58, , 16F
03/23 17:58, 16F
AndroidDev 近期熱門文章
PTT數位生活區 即時熱門文章