Android - Collection.shuffle返回变量

时间:2016-12-15 21:07:41

标签: java android

在我的新应用中,我需要从列表中随机播放颜色,然后将其分配给变量。变量返回什么?我认为变量会返回颜色,例如colorone == Color.RED,但是当我打印它们时,它们会返回值-256,-65536,-16776961和-16711936,有没有办法让它们返回颜色?

public class MainActivity extends Activity
{                   
       public int colorone;
       public int colortwo;
       public int colorthree;
       public int colorfour;

       @Override
       protected void onCreate(Bundle savedInstanceState){   
                 super.onCreate(savedInstanceState);                       
                 setContentView(R.layout.activity_game);    

                 shuffle();                              
       }

            private void shuffle() {
                // TODO Auto-generated method stub
                 List<Integer> numbers = Arrays.asList(Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW);
                 Collections.shuffle(numbers);


                 colorone = numbers.get(0);                      
                 colortwo = numbers.get(1);
                 colorthree = numbers.get(2);
                 colorfour = numbers.get(3);


             }
} 

0 个答案:

没有答案