Gostaria de embaralhar um ArrayList, e estou tentando fazer isso com o Collections.sort(), porém acho que não está acontecendo
O código que estou usando é esse:
Thread t = new Thread(new Runnable() {
@Override
public void run() {
ImageView imageView = findViewById(R.id.imagePadrao);
int m = 0;
int n = 0;
List<Integer> op = new ArrayList<Integer>();
op.add(R.drawable.pedra);
op.add(R.drawable.papel);
op.add(R.drawable.tesoura);
Collections.sort( op );
Iterator iterator = op.iterator();
for (int i = 0; i < 6; i++){
n++;
Log.d("Incremento", ""+n);
while (iterator.hasNext()){
m = (int) iterator.next();
Log.d( "Numero", ""+m );
imageView.setImageResource( m );
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Collections.sort( op );
iterator = op.iterator();
}
}
});
t.start();
Para saber se está embaralhando estou olhando o console e para sempre ser a mesma sequência
07-31 12:05:54.591 6136-6168/com.use.jokenpo D/Incremento: 1
07-31 12:05:54.591 6136-6168/com.use.jokenpo D/Numero: 2131099747
07-31 12:05:54.694 6136-6168/com.use.jokenpo D/Numero: 2131099749
07-31 12:05:54.797 6136-6168/com.use.jokenpo D/Numero: 2131099762
07-31 12:05:54.901 6136-6168/com.use.jokenpo D/Incremento: 2
07-31 12:05:54.901 6136-6168/com.use.jokenpo D/Numero: 2131099747
07-31 12:05:55.004 6136-6168/com.use.jokenpo D/Numero: 2131099749
07-31 12:05:55.107 6136-6168/com.use.jokenpo D/Numero: 2131099762
07-31 12:05:55.211 6136-6168/com.use.jokenpo D/Incremento: 3
07-31 12:05:55.211 6136-6168/com.use.jokenpo D/Numero: 2131099747
07-31 12:05:55.317 6136-6168/com.use.jokenpo D/Numero: 2131099749
07-31 12:05:55.419 6136-6168/com.use.jokenpo D/Numero: 2131099762
07-31 12:05:55.522 6136-6168/com.use.jokenpo D/Incremento: 4
07-31 12:05:55.522 6136-6168/com.use.jokenpo D/Numero: 2131099747
07-31 12:05:55.626 6136-6168/com.use.jokenpo D/Numero: 2131099749
07-31 12:05:55.729 6136-6168/com.use.jokenpo D/Numero: 2131099762
07-31 12:05:55.832 6136-6168/com.use.jokenpo D/Incremento: 5
07-31 12:05:55.832 6136-6168/com.use.jokenpo D/Numero: 2131099747
07-31 12:05:55.936 6136-6168/com.use.jokenpo D/Numero: 2131099749
07-31 12:05:56.040 6136-6168/com.use.jokenpo D/Numero: 2131099762
07-31 12:05:56.143 6136-6168/com.use.jokenpo D/Incremento: 6
07-31 12:05:56.143 6136-6168/com.use.jokenpo D/Numero: 2131099747
07-31 12:05:56.250 6136-6168/com.use.jokenpo D/Numero: 2131099749
07-31 12:05:56.353 6136-6168/com.use.jokenpo D/Numero: 2131099762
Gostaria que toda vez que rodasse o loop ele embaralhasse novamente