I have an array of strings (in strings.xml), in which I collect all my games
<string-array name="games">
<item name="select" translatable="false">...</item>
<item name="game_fortnite" translatable="false">Fortnite</item>
<item name="game_csgo" translatable="false">CounterStrike: Global Offensive</item>
<item name="game_minecraft_minigames" translatable="false">Minecraft Minigames</item>
</string-array>
I am now trying to get a specific item (In this case the first one, but I will need others later) from this array. Since i can give the items names, without Android Studio underlining it for me, I thought maybe i can refer to the strings by names, which does not work in any way I tried it.
In this case I am trying to find out wheter my string variable "game" has the same value as the array item I have named "select". I have tried all of the following:
if(game.equals(R.array.games.select)){
}
if(game.equals(R.string.games.select)){
}
if(game.equals(R.array.games[0])){
}
if(game.equals(R.array.select)){
}
I heve tried, as you can see, using an index (didn't work), but I'd like a possibility to refer to them by their name property.
