我在Android中使用日历视图。我想在日历视图中更改特定的文本颜色,但我找不到像setSelectedDateTextColor(int color)
这样的方法。请告诉我如何实现这一目标。
答案 0 :(得分:0)
这对我来说是完美的工作。试试吧。
private void initializeCalendar() {
// TODO Auto-generated method stub
CalendarView cvCalendar = null;
cvCalendar.setShowWeekNumber(false);
cvCalendar.setFirstDayOfWeek(1);
cvCalendar.setSelectedWeekBackgroundColor(getResources().getColor(
R.color.darkgray));
cvCalendar.setUnfocusedMonthDateColor(getResources().getColor(
R.color.darkgray));
cvCalendar.setWeekSeparatorLineColor(getResources().getColor(
R.color.white));
cvCalendar.setSelectedDateVerticalBar(R.color.white);
cvCalendar.setSelected(false);
cvCalendar.setOnDateChangeListener(new OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year,
int month, int day) {
// TODO Auto-generated method stub
// cvCalendar.canScrollVertically(day);
Calendar c = Calendar.getInstance();
c.set(year, month, day);
month = month + 1;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
formattedDate = sdf.format(c.getTime());
}
});
}