//我为图像做了数组,并嵌套循环重复6次,当我运行仿真器生成"hello world“时,如何在仿真器中查看它们?
package com.example.abc;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
Integer []arr = new Integer [] {R.drawable.candy1, R.drawable.candy2, R.drawable.candy3,
R.drawable.candy4,R.drawable.candy5 ,R.drawable.candy6};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
shuffleArray();
}
private void shuffleArray() {
// TODO Auto-generated method stub
List<Integer> pictures = new ArrayList<Integer>();
for(int i=0; i<6; i++){
for (int j=0 ; j<6 ; j++)
{
pictures.add(arr[j]);
Collections.shuffle(pictures);
}
}
}
}
发布于 2014-12-19 22:49:44
相反,
private void shuffleArray() {
// TODO Auto-generated method stub
List<Integer> pictures = new ArrayList<Integer>();
for(int i=0; i<6; i++){
for (int j=0 ; j<6 ; j++)
{
pictures.add(arr[j]);
Collections.shuffle(pictures);
}
}
}
试试这个:
private void shuffleArray() {
// TODO Auto-generated method stub
List<Integer> pictures = new ArrayList<Integer>();
for(int i=0; i < arr.length; i++){
pictures.add(arr[j]);
Collections.shuffle(pictures);
}
}
https://stackoverflow.com/questions/27567720
复制相似问题