在日历中,当我选择日期时,我需要更改网格项的背景颜色,并删除先前所选项的背景。当我点击并按住日期10时(如图2所示),它显示橙色。但是当我没有聚焦鼠标时,它没有显示颜色。
gridcell.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
String date_month_year = (String) v.getTag();
selected_date = date_month_year;
String[] day_color = date_month_year.split("-");
String theday = day_color[0];
selectedDateEvents(theday);
listadapter.notifyDataSetChanged();
prev_pos = cur_pos;
cur_pos = position;
Log.d("curr and prev", position+" n "+prev_pos);
parent.getChildAt(cur_pos).setBackgroundResource(R.drawable.calendar_tile_small);
parent.getChildAt(prev_pos).setBackgroundResource(R.drawable.calendar_tile_small_black);
GridCellAdapter.this.notifyDataSetChanged();
}
});
有人可以帮助我吗?