改变gridview颜色 android的gridview中获取到了一系列客户数据,现在我想让这些信息随即改变颜色,以此来区别,请问有没有比较好的方法啊????? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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;这样对吗? 提问 关于StringBuffer简单问题 java.sql.SQLException:no suitable driver 关于 大数据量顺序进行处理机制 怎么把零散的年、月、日变量赋值给date对象。 POI, 操作[.xls]文件, 怎么在指定位置,插入一个新行 如何把一个Java程序做成Windows服务 java制作安装程序? 请问各位:如何编译Java的程序。多谢! 请教一个对象赋值问题。 请教一个JAVA 解析XML的问题 非常感谢 Java调试
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;这样对吗?