Hello Rincy,
The selection of the today date is something we decided to include in the upcoming release in February. However I am offering you a workaround for the time being. I am giving you the modified code including your previous ticket and this one as well:
private
RadCalendarView calendarView;
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this
.calendarView =
new
RadCalendarView(
this
);
this
.calendarView.setAdapter(
new
CustomCalendarAdapter(
this
.calendarView));
this
.calendarView.getEventAdapter().setRenderer(
new
CustomEventRenderer(
this
));
List<Event> events =
new
ArrayList<>();
events.add(
new
Event(
"Event"
, Calendar.getInstance().getTimeInMillis(), Calendar.getInstance().getTimeInMillis() + 1));
this
.calendarView.getEventAdapter().setEvents(events);
this
.calendarView.getAdapter().setStyle(CalendarStyles.light(
this
));
setContentView(
this
.calendarView);
}
private
static
class
CustomCalendarAdapter extends CalendarAdapter {
public
CustomCalendarAdapter(RadCalendarView owner) {
super(owner);
}
@Override
protected
CalendarDayCell generateCalendarDayCell() {
return
new
CustomCalendarDayCell(
this
.owner);
}
@Override
public
void
updateDayNameCell(CalendarCell convertCell,
int
index) {
super.updateDayNameCell(convertCell, index);
convertCell.setText(convertCell.getText().substring(0, 1));
}
}
private
static
class
CustomCalendarDayCell extends CalendarDayCell {
private
static
final
int
SELECTED_COLOR = Color.parseColor(
"#38b4db"
);
private
static
final
int
IDLE_COLOR = Color.parseColor(
"#ffffff"
);
public
CustomCalendarDayCell(RadCalendarView owner) {
super(owner);
}
@Override
protected
void
drawEvents(Canvas canvas) {
if
(
this
.getEvents() !=
null
&&
this
.getEvents().size() > 0)
this
.owner.getEventAdapter().getRenderer().renderEvents(canvas,
this
);
}
@Override
protected
void
updateBackgroundColor() {
if
(
this
.isSelected())
setBackgroundColor(SELECTED_COLOR);
else
setBackgroundColor(IDLE_COLOR);
}
}
private
static
class
CustomEventRenderer extends EventRenderer {
private
static
final
int
COLOR_IDLE = Color.parseColor(
"#38b4db"
);
private
static
final
int
COLOR_SELECTED = Color.parseColor(
"#ffffff"
);
private
float
size;
private
Paint paint;
public
CustomEventRenderer(Context context) {
super(context);
this
.size = Util.getDimen(TypedValue.COMPLEX_UNIT_DIP, 20);
this
.paint =
new
Paint(Paint.ANTI_ALIAS_FLAG);
}
@Override
public
void
renderEvents(Canvas canvas, CalendarDayCell cell) {
Path path =
new
Path();
path.moveTo(cell.getRight() -
this
.size, cell.getBottom());
path.lineTo(cell.getRight(), cell.getBottom());
path.lineTo(cell.getRight(), cell.getBottom() -
this
.size);
path.close();
if
(cell.isSelected())
this
.paint.setColor(COLOR_SELECTED);
else
this
.paint.setColor(COLOR_IDLE);
canvas.drawPath(path,
this
.paint);
}
}
Please let me know if this works for you.
Regards,
Antony Jekov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.