title: Display the List of Events Within the Calendar?
body: <p>I am able to Display the Events Within the List below the Calendar but i want to Display the <strong>Events Within the Calendar</strong> through the JSON Data.I have used CalendarView for Showing the Calendar.I have watched <a href="https://stackoverflow.com/questions/43262036/android-calendar-with-events">this</a> but not able to solve what i exactly Wanted.</p>
  
  <p><strong>xml</strong></p>
  
  <pre><code>  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="#2E353D"
          android:orientation="vertical"&gt;
  
          &lt;LinearLayout
              android:layout_width="wrap_content"
              android:layout_height="40dp"
              android:layout_gravity="center_horizontal"
              android:orientation="horizontal"&gt;
  
              &lt;ImageView
                  android:layout_width="30dp"
                  android:layout_height="match_parent"
                  android:padding="3dp"
                  android:src="@mipmap/calander" /&gt;
  
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="center_vertical"
                  android:layout_marginLeft="8dp"
                  android:text="Calendar"
                  android:textColor="#fff"
                  android:textSize="17dp"
                  android:textStyle="bold" /&gt;
  
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
  
  
        &lt;com.prolificinteractive.materialcalendarview.MaterialCalendarView
              android:id="@+id/calendar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_centerInParent="true" /&gt;
  
  
      &lt;!--  &lt;CalendarView
          android:id="@+id/calendar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_centerInParent="true" /&gt;     --&gt;
  
  
      &lt;ListView
          android:id="@+id/calenderlist"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" /&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>CalenderFragment</strong></p>
  
  <pre><code>  public class CalenderFragment extends Fragment implements OnMonthChangedListener {
      String Navigation_URL = "http://192.168.100.5:84/api/academics/getEvents";
      String access_token;
      ListView listView;
      com.prolificinteractive.materialcalendarview.MaterialCalendarView calendarView;
      ArrayList&lt;CalenderPojoStudent&gt; student_list_calender = new ArrayList&lt;&gt;();
  
      private HashMap&lt;Integer, List&lt;Event&gt;&gt; map = new HashMap&lt;&gt;();
      private List&lt;CalendarDay&gt; calevents = new ArrayList&lt;&gt;();
  
      private Calendar cal;
      private List&lt;Event&gt; eventList = new ArrayList&lt;&gt;();
  
  
      private MyAdapterCalendar adapter;
  
      private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.calender, container, false);
          getActivity().setTitle("");
          setHasOptionsMenu(true);
  
          calendarView = (com.prolificinteractive.materialcalendarview.MaterialCalendarView) view.findViewById(R.id.calendar);
          final Calendar calendar = Calendar.getInstance();
          calendarView.setSelectedDate(calendar.getTime());
          calendarView.setSelectedDate(calendar.getTime());
  
  
          listView = (ListView) view.findViewById(R.id.calenderlist);
          adapter = new MyAdapterCalendar(getActivity(), eventList);
         // listView.setAdapter(adapter);
  
          //  calendarView.addDecorator(new HighlightWeekendsDecorator());
          calendarView.addDecorator(new OneDayDecorator());
          // calendarView.addDecorator(new EventDecorator(Color.RED, calendarDays));
          // calendarView.addView(onMonthChanged(calendarView,date));
          // calendarView.addDecorator(new EventDecorator(Color.RED, calendarDays));
          //calendarView.addDecorator(new MySelectorDecorator(getActivity()));
  
  
          // calendarView.addDecorator(new EventDecorator("#FF0000",student_list_calender));
          //  calendarView.addDecorator(new EventDecorator("",));
          //calendarView.setDateTextAppearance(View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE);
  
  
          SessionManagement session = new SessionManagement(getContext());
          session.checkLogin();
          access_token = session.getAccesstToken();
          makeJsonObjectRequest();
  
  
          return view;
      }
  
      // List&lt;Event&gt; events = new ArrayList&lt;&gt;();
  
  
      private void makeJsonObjectRequest() {
  
          RequestQueue requestQueue = Volley.newRequestQueue(getContext());
          String URL = Navigation_URL;
  
  
          StringRequest stringRequest = new StringRequest(Request.Method.GET, URL,
                  new Response.Listener&lt;String&gt;() {
                      @Override
                      public void onResponse(String response) {
                          try {
  
  
                              JSONArray jArray = new JSONArray(response);
                              for (int i = 0; i &lt; jArray.length(); i++) {
                                  JSONObject jsonObject = jArray.getJSONObject(i);
                                  String StartDate = jsonObject.getString("StartDate");
                                  String Title = jsonObject.getString("Title");
  
  
                                  try {
                                      Date date = simpleDateFormat.parse(StartDate);
  
                                      Log.d("Date ", "" + date);
                                      CalendarDay day1 = CalendarDay.from(date);
                                      Event event = new Event(date, Title);
                                      cal = Calendar.getInstance();
                                      cal.setTime(date);
                                      int month = cal.get(Calendar.MONTH);
                                      if (!map.containsKey(month)) {
                                          List&lt;Event&gt; events = new ArrayList&lt;&gt;();
                                          events.add(event);
                                          map.put(month, events);
                                      } else {
                                          List&lt;Event&gt; events = map.get(month);
                                          events.add(event);
                                          map.put(month, events);
  
                                      }
                                      calevents.add(day1);
  
                                  } catch (ParseException e) {
                                      e.printStackTrace();
                                  }
  
  
                              }
  
                              //CalenderAdapter calenderAdapter = new CalenderAdapter(getActivity(), student_list_calender);
                              //listView.setAdapter(calenderAdapter);
                              cal = Calendar.getInstance();
                              int month = cal.get(Calendar.MONTH);
                              List&lt;Event&gt; event = map.get(month);
                              if (event != null &amp;&amp; event.size() &gt; 0)
                                  adapter.addItems(event);
                              listView.setAdapter(adapter);
                              EventDecorator eventDecorator = new EventDecorator(Color.RED, calevents);
                              calendarView.addDecorator(eventDecorator);
  
                          } catch (JSONException e) {
                              makeText(getContext(), "Fetch failed!", LENGTH_SHORT).show();
                              e.printStackTrace();
                          }
  
                          //
                      }
  
                  }, new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                  makeText(getContext(), error.toString(), LENGTH_LONG).show();
              }
          }) {
  
              @Override
              public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
                  Map&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
                  headers.put("Authorization", "Bearer " + access_token);
                  headers.put("Content-Type", "application/x-www-form-urlencoded");
                  return headers;
              }
  /*
              @Override
              protected Map&lt;String, String&gt; getParams() throws com.android.volley.AuthFailureError {
                  Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                  map.put("id", master_id);
                  map.put("accessID", accessID);
                  map.put("currentUser", master_id);
                  return map;
  
              } */
          };
  
  
          requestQueue.add(stringRequest);
  
      }
  
  
      @Override
      public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
          // TODO Auto-generated method stub
          super.onCreateOptionsMenu(menu, inflater);
          inflater.inflate(R.menu.dashboard, menu);
      }
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // handle item selection
          switch (item.getItemId()) {
              case R.id.action_settings:
                  // do s.th.
                  return true;
              default:
                  return super.onOptionsItemSelected(item);
          }
      }
  
  
      @Override
      public void onMonthChanged(MaterialCalendarView widget, CalendarDay date) {
  
  
          // CalenderAdapter calenderAdapter = new CalenderAdapter(getActivity(), student_list_calender);
          // listView.setAdapter(calenderAdapter);
          Calendar cal = Calendar.getInstance();
          cal.setTime(date.getDate());
          int month = cal.get(Calendar.MONTH);
          List&lt;Event&gt; event = map.get(month);
          if (event != null &amp;&amp; event.size() &gt; 0)
              adapter.addItems(event);
  
          widget.invalidateDecorators();
  
      }
  
  
  }
  </code></pre>
  
  <p><strong>EventDecorator</strong></p>
  
  <pre><code>      public class EventDecorator implements DayViewDecorator {
  
  /*
      private final Drawable drawable;
      private final CalendarDay day;
      private final int color;
  
  
      public EventDecorator(MaterialCalendarView view, Date date, int colors) {
  //       super(view);
  
          this.day = CalendarDay.from(date);
          this.color = colors;
          this.drawable = createTintedDrawable(view.getContext(), color);
      }
  
  
      @Override
      public boolean shouldDecorate(CalendarDay day) {
          if (this.day.equals(day)) {
              return true;
          }
          return false;
      }
  
      @Override
      public void decorate(DayViewFacade view) {
          view.setSelectionDrawable(drawable);
      }
  
      private static Drawable createTintedDrawable(Context context, int color) {
          return applyTint(createBaseDrawable(context), color);
      }
  
      private static Drawable applyTint(Drawable drawable, int color) {
          Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
          DrawableCompat.setTint(wrappedDrawable, color);
          return wrappedDrawable;
      }
  
      private static Drawable createBaseDrawable(Context context) {
          return ContextCompat.getDrawable(context, R.drawable.ic_menu_send);
      }
  
  
     */
  
      private int color;
      private HashSet&lt;CalendarDay&gt; dates;
  
      public EventDecorator(int color, Collection&lt;CalendarDay&gt; dates) {
          this.color = color;
          this.dates = new HashSet&lt;&gt;(dates);
      }
  
      @Override
      public boolean shouldDecorate(CalendarDay day) {
          return dates.contains(day);
      }
  
      @Override
      public void decorate(DayViewFacade view) {
          view.addSpan(new DotSpan(5, color));
      }
  }
  </code></pre>
  
  <p><strong>Event</strong></p>
  
  <pre><code>  public class Event {
  
      private Date date;
      private String events;
  
      public Event(Date date, String events) {
          this.date = date;
          this.events = events;
  
      }
  
      public Date getDate() {
          return date;
      }
  
      public String getEvents() {
          return events;
      }
  }
  </code></pre>
  
  <p><strong>MyAdapterCalendar</strong></p>
  
  <pre><code>public class MyAdapterCalendar extends ArrayAdapter&lt;Event&gt; {
  
      private List&lt;Event&gt; list;
      private LayoutInflater mInflater;
  
      public MyAdapterCalendar(Context context, List&lt;Event&gt; list) {
          super(context, R.layout.activity_calendar_event, list);
          this.mInflater = LayoutInflater.from(context);
          this.list = list;
      }
  
      static class ViewHolder {
          TextView text;
  
      }
  
      public void addItems(List&lt;Event&gt; list) {
          this.list.clear();
          this.list.addAll(list);
          notifyDataSetChanged();
  
      }
  
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          ViewHolder viewHolder;
  
          if (convertView == null) {
  
              convertView = mInflater.inflate(R.layout.activity_calendar_event, parent, false);
              viewHolder = new ViewHolder();
              viewHolder.text = (TextView) convertView.findViewById(R.id.label);
  
              convertView.setTag(viewHolder);
          } else {
              viewHolder = (ViewHolder) convertView.getTag();
          }
  
          viewHolder.text.setText(list.get(position).getEvents());
  
          return convertView;
      }
  }
  </code></pre>
  
  <p><strong>activity_calendar_event</strong></p>
  
  <p>&lt;</p>
  
  <pre><code>RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
  
      &lt;TextView
          android:id="@+id/label"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:text="Hello World"
          android:textSize="20sp"&gt;&lt;/TextView&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>JSON</strong></p>
  
  <pre><code>[
    {
      "EventID": 1011,
      "Title": "May Day",
      "Description": "Holiday for the International Labour Day",
      "StartDate": "2017-05-01T00:00:00",
      "StartTime": "00:00:00",
      "EndDate": "2017-05-02T00:00:00",
      "EndTime": "00:00:00",
      "IsFullDay": true,
      "IsHoliday": false,
      "DateTime": null
    },
    {
      "EventID": 1020,
      "Title": "d",
      "Description": "",
      "StartDate": "2017-04-27T00:00:00",
      "StartTime": "05:45:00",
      "EndDate": "2017-04-27T00:00:00",
      "EndTime": "05:45:00",
      "IsFullDay": false,
      "IsHoliday": false,
      "DateTime": null
    },
    {
      "EventID": 1019,
      "Title": "Mother's Day",
      "Description": "Mother's day",
      "StartDate": "2017-04-26T00:00:00",
      "StartTime": "10:00:00",
      "EndDate": "2017-04-26T00:00:00",
      "EndTime": "18:00:00",
      "IsFullDay": false,
      "IsHoliday": false,
      "DateTime": null
    }
  ]
  </code></pre>
  
  <blockquote>
    <p>I want to display the dot under certain date,which shows as event.And
    specific month should list specific month event rather than all the
    event ,which is the one i am getting on Currently.</p>
  </blockquote>