This is a migrated thread and some comments may be shown as answers.

radcalendar events

1 Answer 60 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paul
Top achievements
Rank 1
Paul asked on 01 Mar 2015, 12:26 AM
I'm testing out radcalender in an application I'm writing. I'm having a tough time making events show up on the calendar for a month. I create the event in the event array and setEvents in the getEventAdapter. Finally I notifyDatachanged and nothing shows on the calendar. What am I doing wrong? I just want a blue event to show up in Feb 17, 2015. I'm following the example code and events just don't display.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
:
:
    calendarView.getEventAdapter().setEvents(generateEvents2());
    calendarView.notifyDataChanged();
        
    return root;
}

private ArrayList<Event> generateEvents2() {
        ArrayList<Event> events = new ArrayList<Event>();

        Calendar c = getToday();
        String fromdate = "2015-02-17T18:00:00";
        String todate = fromdate;
       
        c = (stringToDateCalendar(fromdate));
        c.set(Calendar.HOUR_OF_DAY, 20);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        long start = c.getTimeInMillis();
       
        c = (stringToDateCalendar(todate));
        c.set(Calendar.HOUR_OF_DAY, 20);
        c.set(Calendar.MINUTE, 1);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        long end = c.getTimeInMillis();
       
        String desc = "booster stuff";
       
        Event eventitem = new Event(desc, start, end);
        eventitem.setEventColor(blueevent);
        events.add(eventitem);
        
        Collections.sort(events, new Comparator<Event>() {
            @Override
            public int compare(Event event, Event event2) {
                return (event.getStartDate() < event2.getStartDate()) ? -1 : (event.getStartDate() > event2.getStartDate()) ? 1 : 0;
            }
        });
        
        return events;
}

private static Calendar stringToDateCalendar(String date1) {

   SimpleDateFormat form = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
   java.util.Date d1 = null;
   Calendar tdy1;
   
   try {
       d1 = form.parse(date1);
   } catch (java.text.ParseException e) {
       e.printStackTrace();
   }
   tdy1 = Calendar.getInstance();
   tdy1.setTime(d1);
   return tdy1;
}

private int getColor(String color)
{
int mycolor=0;
if (color.toUpperCase().equals("BLUE"))
{
mycolor = blueevent;
}
if (color.toUpperCase().equals("GREEN"))
{
mycolor = greenevent;
}
if (color.toUpperCase().equals("ORANGE"))
{
mycolor = orangeevent;
}
if (color.toUpperCase().equals("PURPLE"))
{
mycolor = purpleevent;
}
if (color.toUpperCase().equals("RED"))
{
mycolor = redevent;
}
if (color.toUpperCase().equals("WHITE"))
{
mycolor = whiteevent;
}
if (color.toUpperCase().equals("YELLOW"))
{
mycolor = yellowevent;
}
return(mycolor);
}



1 Answer, 1 is accepted

Sort by
0
Antony Jekov
Telerik team
answered on 04 Mar 2015, 10:08 AM
Closing as duplicate of ticket 912059.

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.

 
Tags
Calendar
Asked by
Paul
Top achievements
Rank 1
Answers by
Antony Jekov
Telerik team
Share this question
or