android的gridview中获取到了一系列客户数据,现在我想让这些信息随即改变颜色,以此来区别,请问有没有比较好的方法啊?????

解决方案 »

  1.   

    public View getView(int position, View convertView, ViewGroup parent) {





        convertView=mInflater.inflate(R.layout._gridview_items, null); 
          TextView   textView=(TextView) convertView.findViewById(R.id._item_text);
          if(data!=null&&data.size()>0){
         textView.setText(data.get(position).getMark().getMarkName());
         textView.setTextColor(Color.YELLOW);      Random random = new Random();
    int[] nums = new int[5];
            for (int i=0; i<5; i++) {
                    int p = random.nextInt(5);
                    if (nums[p] != 0)
                            i--;
                    else
                            nums[p] = i;
            }
            for (int i=0; i<5; i++) {
                    System.out.println("+++++iiiiii++++---------->" + nums[i]);
                    if(nums[i] == 1) {
                     textView.setBackgroundColor(Color.BLUE);
                    }
                    else if(nums[i] == 2) {
                     textView.setBackgroundColor(Color.RED);
                    }
                    else if(nums[i] == 3) {
                     textView.setBackgroundColor(Color.GREEN);
                    }
            }
          }
    return convertView;这样对吗?