Java中的事件处理
所以我在Android Studio中用Java语言编程,在一个非常基本的层面上。但是,我需要帮助创建一些事件处理 我使用CalendarView功能制作了一个日历,如下所示 我需要创建一个函数,让我(点击一个日期)为那天创建一个事件,我真的不知道怎么做 有没有可能做到这一点 提前感谢你的帮助Java中的事件处理,java,android,event-handling,calendarview,Java,Android,Event Handling,Calendarview,所以我在Android Studio中用Java语言编程,在一个非常基本的层面上。但是,我需要帮助创建一些事件处理 我使用CalendarView功能制作了一个日历,如下所示 我需要创建一个函数,让我(点击一个日期)为那天创建一个事件,我真的不知道怎么做 有没有可能做到这一点 提前感谢你的帮助 private void initializeCalendar() { calendar = (CalendarView) findViewById(R.id.calendar); //
private void initializeCalendar() {
calendar = (CalendarView) findViewById(R.id.calendar);
//sets whether to show the week number.
calendar.setShowWeekNumber(false);
//sets the first day of the week according to the Calendar.
//here we set Monday as the first day of the Calendar.
calendar.setFirstDayOfWeek(2);
//The background color for the selected week.
calendar.setSelectedWeekBackgroundColor(getResources().getColor(R.color.green));
//sets the color for the dates of an unfocused month
calendar.setUnfocusedMonthDateColor(getResources().getColor(R.color.transparent));
//sets the color for the seperator line between weeks.
calendar.setWeekSeparatorLineColor(getResources().getColor(R.color.transparent));
//sets the color for the vertical bar shwon at the beginning and at the end of the selected date.
calendar.setSelectedDateVerticalBar(R.color.darkgreen);
//sets the listener to be notified upon selected date change.
calendar.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
Toast.makeText(getApplicationContext(), dayOfMonth + "/" + month + "/" + year, Toast.LENGTH_LONG).show();
}
});
}
创建事件意味着在移动日历或应用程序中创建事件?最好是在应用程序日历中创建事件,但是如果这很难做到和/或需要大量编码,可以使用移动日历。我认为最好的方法是在用户创建事件时将事件保存在DB中,并将该日期以不同颜色加载到日历中。同样,应用程序需要在那天做任何特别的事情吗?如果是,您可能还需要为该事件日期添加报警服务。该应用程序将在该日期发出某种报警。但首先,我需要创建一个函数,用户可以在其中为特定日期创建事件,可能带有一些复选框选项。