Closed cristidan94 closed 7 years ago
@cristidan94 thank you for your reporting! I made a PR: https://github.com/khacpv/Calendar-Day-View/pull/2 to update event color.
to set color, you might need to use CalendarDayView.setEvents(List)
after change data.
for example:
((CdvDecorationDefault) (dayView.getDecoration())).setOnEventClickListener(
@Override
public void onEventViewClick(View view, EventView eventView, IEvent data) {
// change data (ex: set event color)
((Event) data).setColor(Color.RED);
// refresh data
dayView.setEvents(events);
or you can create your own Decoration to fit your desired.
@khacpv Thank you for your fast answer, now it does work just as you said it would, using the .setEvents(events) to invalidate/redraw. One more question, You can see in this screenshot I have some events. Each event has in its top left corner and top right corner some characters(in the left I have the date and in the right some chinese characters?). I really want to set the visibility of this fields to Invisible/Gone. Is there any way to do that? Thanks again for the support!
@cristidan94 to hide header texts, you should create your own decoration. Then find and hide them:
public class CustomDecoration extends CdvDecorationDefault {
public DayViewDecoration(Context context) {
super(context);
}
@Override
public EventView getEventView(final IEvent event, Rect eventBound, int hourHeight,
int seperateHeight) {
final EventView eventView =
super.getEventView(event, eventBound, hourHeight, seperateHeight);
// hide event name
TextView textEventName = (TextView) eventView.findViewById(com.framgia.library.calendardayview.R.id.item_event_name);
textEventName.setVisibility(View.INVISIBLE);
// hide event header
TextView textHeader1 = (TextView) eventView.findViewById(com.framgia.library.calendardayview.R.id.item_event_header_text1);
TextView textHeader2 = (TextView) eventView.findViewById(com.framgia.library.calendardayview.R.id.item_event_header_text2);
textHeader1.setVisibility(View.GONE);
textHeader2.setVisibility(View.GONE);
return eventView;
}
@Override
public PopupView getPopupView(final IPopup popup, Rect eventBound, int hourHeight,
int seperateH) {
PopupView popupView = super.getPopupView(popup, eventBound, hourHeight, seperateH);
// popupView.show();
CardView cardView = (CardView) popupView.findViewById(com.framgia.library.calendardayview.R.id.cardview);
TextView textQuote = (TextView) popupView.findViewById(com.framgia.library.calendardayview.R.id.quote);
TextView textTitle = (TextView) popupView.findViewById(com.framgia.library.calendardayview.R.id.title);
ImageView imvEnd = (ImageView) popupView.findViewById(com.framgia.library.calendardayview.R.id.imv_end);
// do something with views
return popupView;
}
}
Works like a charm! Thank you, really useful library!
Hello! It seems I am unable the set a color of the event to be created. I also need to change the color after an action has been performed on an event(on click). How do I achieve this? Thank you! I even tried your example, I logged the values parsed to the Event constructor and it prints the int representation (example: -49023 ), but I can't get to sort it out.