如何在android中的日历上的特定日期设置点

【如何在android中的日历上的特定日期设置点】胸怀万里世界, 放眼无限未来。这篇文章主要讲述如何在android中的日历上的特定日期设置点相关的知识,希望能为你提供帮助。
这是点击日期的代码显示事件,但在事件日期我看不到可见DOT我试图做但没有发生任何事情。

package com.example.mis_internee.mycalentest; import android.content.Context; import android.graphics.Color; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; import com.github.sundeepk.compactcalendarview.CompactCalendarView; import com.github.sundeepk.compactcalendarview.domain.Event; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import static android.graphics.Color.RED; public class MainActivity extends AppCompatActivity {CompactCalendarView compactCalendar; private SimpleDateFormat dateFormatMonth = new SimpleDateFormat("MMMM- yyyy", Locale.getDefault()); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(null); compactCalendar = (CompactCalendarView) findViewById(R.id.compactcalendar_view); compactCalendar.setUseThreeLetterAbbreviation(true); compactCalendar.setEventIndicatorStyle(Color.BLACK); compactCalendar.setCurrentDayBackgroundColor(RED); compactCalendar.getEvents(3223213); //Set an event for Teachers' Professional Day 2016 which is 21st of OctoberEvent ev1 = new Event(Color.BLACK, 1477040400000L, "Teachers' Professional Day"); compactCalendar.addEvent(ev1); compactCalendar.setListener(new CompactCalendarView.CompactCalendarViewListener() { @Override public void onDayClick(Date dateClicked) { Context context = getApplicationContext(); if (dateClicked.toString().compareTo("Fri Jan 26 00:00:00 GMT+05:00 2018") == 0) { Toast.makeText(context, "Teachers' Professional Day", Toast.LENGTH_SHORT).show(); }else { Toast.makeText(context, "No Events Planned for that day", Toast.LENGTH_SHORT).show(); }}@Override public void onMonthScroll(Date firstDayOfNewMonth) { actionBar.setTitle(dateFormatMonth.format(firstDayOfNewMonth)); } }); } }

提前致谢
答案你在这里设置时间戳1477040400000L
Event ev1 = new Event(Color.BLACK, 1477040400000L, "Teachers' Professional Day"); compactCalendar.addEvent(ev1);

时间戳1477040400000LFriday, 21 October 2016 09:00:00 GMT +5:30所以检查那个日期
如果你想设置Fri Jan 26 00:00:00 GMT+05:00 2018设置
Event ev1 = new Event(Color.BLACK,1516924800000L, "Teachers' Professional Day"); compactCalendar.addEvent(ev1);

如何在android中的日历上的特定日期设置点

文章图片


    推荐阅读