I succeeded in getString using getSystem. But I want to know how to use local string. If you know the answer to this problem, can you help me? Thanks in advance for those of you who know the answer.
class QList {
companion object {
val qList = listOf(
Resources.getSystem().getString(android.R.string.cancel),
"AAAA", "BBBB", "CCCC"
)
fun getQList(): ArrayList<Question> {
var qlist = ArrayList<Question>()
for(num in qList.indices) {
qlist.add(Question(num 1, qList[num], "", ""))
}
return qlist
}
}
}
CodePudding user response:
You need to pass context to QList class and after getting context you can simply call below line
context.getString(R.string.txt_your_string_name)
CodePudding user response:
getString using getSystem should work for local string, just import your project's .R to your utils class.