我正在创建一个calendar
,我用过grid view to display the dates in that calendar
。现在我想在用户选择每个网格项时更改每个网格项的背景。这里背景随着用户点击特定日期而改变,但之前的项目或日期的背景没有回滚到原来的?我怎样才能做到这一点?例如:如果我单击第一个网格视图项目,该项目变为蓝色,当我单击项目 2 时,项目 #2 的颜色变为蓝色,但第一个项目保持相同颜色,我不希望发生这种情况. 如何将第一项颜色更改为默认颜色。
if(cur_posn == 0){
cur_posn = position;
old_posn = position;
v.setBackgroundResource(R.drawable.calendar_tile_green);
}
else {
cur_posn = position;
parent.getChildAt(old_posn).setBackgroundResource(R.drawable.calendar_tile_small);
v.setBackgroundResource(R.drawable.calendar_tile_green);
old_posn = cur_posn;
}