Randomize string from resources android

前端 未结 2 371
忘了有多久
忘了有多久 2021-01-24 18:12

I have tried this:

   int[] trivias = {
        R.string.trivia1, R.string.trivia2, R.string.trivia3, R.string.trivia4, R.string.trivia5,
        R.string.trivi         


        
相关标签:
2条回答
  • 2021-01-24 18:48

    this.. may be..

    tv.setText(trivias[ran.nextInt(trivias.length)]);
    

    What you are doing right now is searching for resource with id, thats generated by ran.nextInt()

    0 讨论(0)
  • 2021-01-24 19:02

    You are not pass int trivias:-

    tv.setText(trivias[ran.nextInt(trivias.length)]);
    

    You just forgot to trivias[]

    0 讨论(0)
提交回复
热议问题