Show random string

前端 未结 3 969
我在风中等你
我在风中等你 2021-01-03 10:43

i am trying to display a random string each time a button is pressed from a set of strings defined in strings.xml . this is an example of the strings ID\'s

&         


        
3条回答
  •  孤城傲影
    2021-01-03 11:08

    Why do you need this?

    R.string.q0

    Assuming getString(RandomQ) is a valid statement, I would think

    int RandomQ = rgenerator.nextInt(5) + 1;
    

    would work just fine.

    Also, as a side note: A lot of times those autofixes in your IDE are unreliable and unsafe to use. Unless you know why it's telling you to do something, don't do it.

提交回复
热议问题