View calendar day / month / week in android

I need an Android calendar view as an attached photo. I already tried this library    https://github.com/alamkanak/Android-Week-View to view the calendar. this is a fixed static event only on the calendar. I could not add a dynamic event to this library calendar view. can anyone suggest any custom library in android.

enter image description here

Android-Week-View sample for calendar library code:

what i tried in this library:

This is the code that statically adds a calendar event. when I run this example, I can see the event on a specific date in the form of a calendar.

 @Override
 public List<WeekViewEvent> onMonthChange(int newYear, int newMonth) {

  // Populate the week view with some events.
    List<WeekViewEvent> events = new ArrayList<WeekViewEvent>();

    Calendar startTime = Calendar.getInstance();
    startTime.set(Calendar.HOUR_OF_DAY, 3);
    startTime.set(Calendar.MINUTE, 0);
    startTime.set(Calendar.MONTH, newMonth-1);
    startTime.set(Calendar.YEAR, newYear);
    Calendar endTime = (Calendar) startTime.clone();
    endTime.add(Calendar.HOUR, 1);
    endTime.set(Calendar.MONTH, newMonth-1);
    WeekViewEvent event = new    WeekViewEvent(1, getEventTitle(startTime),
    startTime, endTime);
    event.setColor(getResources().getColor(R.color.event_color_01));
    events.add(event);
      return events;
    }
    when i click this event on calendar page, its showing that event
    time and date in toast.
     @Override
    public void onEventClick(WeekViewEvent event, RectF eventRect) {
    Toast.makeText(MainActivity.this, "Clicked " 
    + event.getName(), Toast.LENGTH_SHORT).show();
    Log.v("heal", "Clicked "+ event.getName()) ;
   }

Note:

  • I need to add the same event to this calendar dynamically.
  • , .
  • onCreate(). , . - .
+4
1

, . , .

+3

All Articles