i have a problem in randomizing values. what i want to do is :
i have 4 editFields and when i type in all fields and click the button "shuffle players" it should show all the players from editFields down in viewText below randomly and non-repeated.
this my code for onlick function:
public void RandomPlayers(View v1){
EditText text1 = (EditText)findViewById(R.id.editText1);
TextView View1 = (TextView)findViewById(R.id.player1);
EditText text2 = (EditText)findViewById(R.id.editText2);
TextView View2 = (TextView)findViewById(R.id.player2);
EditText text3 = (EditText)findViewById(R.id.editText3);
TextView View3 = (TextView)findViewById(R.id.player3);
EditText text4 = (EditText)findViewById(R.id.editText4);
TextView View4 = (TextView)findViewById(R.id.player4);
String value1 = text1.getText().toString();
String value2 = text2.getText().toString();
String value3 = text3.getText().toString();
String value4 = text4.getText().toString();
String[] players = {value1, value2, value3, value4};
int index = new Random().nextInt(players.length);
String random = (players[index]);
View1.setText(random);
View2.setText(random);
View3.setText(random);
View4.setText(random);
}
but the problem i keep getting the same random name for all Textviews
and here is an image showing the logic error: ![enter image description here][1]
please help me and show me my mistakes thanks