我試圖來連接子系統內置於string.xml
使用此代碼日期的字符串值:的Android getString方法
holder.time.setText(date.getHours()+" " + getString(R.string.ore));
但我recive錯誤:無法解析方法。 我嘗試此代碼:
holder.time.setText(date.getHours()+" " +R.string.ore);
作品,但價值R.string.ore
檢索爲int值,而不是字符串,但我需要一個字符串值 我需要string.xml
使用的值,而不是用一個簡單的字符串例如「礦石」
任何幫助?
請試試看:'getResources()。getString(R.string.ore)' –
這應該在任何地方工作:'holder.time.getContext()。getString(R.string.ore)'。 –