1

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
        }
    }
}
Naetmul
  • 14,544
  • 8
  • 57
  • 81
온송정
  • 37
  • 6

2 Answers2

1

getString using getSystem should work for local string, just import your project's .R to your utils class.

TylerQITX
  • 318
  • 2
  • 9
0

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)
Jaydeep parmar
  • 561
  • 2
  • 15