I'm programming with Android Studio and trying to program a scissors rock paper game. Now I'm programming a highscore where the users can see there records as list of 10 elements.
To insert the name of the players in this List I insert the values in the Textview with:
TextView tempField = findViewById(R.id.playerName1);
tempField.setText(sharedpreferences.getString("name" + i, ""));
Because these are 10 elements and I need to insert 3 values for every element I would like to do this with a for-loop. The problem is that I can't just put a variable with the number after R.id.playerName. I tried:
for(int i = 0; i < 10; i++){
TextView tempField = findViewById("R.id.playerName" + i);
tempField.setText(sharedpreferences.getString("name" + i, ""));
}