gpt4 book ai didi

Android 日历议程 View 事件重叠

转载 作者:行者123 更新时间:2023-11-29 02:39:39 25 4
gpt4 key购买 nike

https://github.com/Tibolte/AgendaCalendarView/issues/119

当使用 baseCalendar 将任何事件添加到事件列表时,它会抛出 java 空指针异常,除了添加事件后,它们都在同一日期显示,该日期是最后一个对象的日期!

https://user-images.githubusercontent.com/29772646/28202935-2f535622-6895-11e7-9062-8a40b6d1752d.png

private void mockList(List eventList) {

Calendar calendar = new GregorianCalendar();
Calendar startTime1 = calendar.getInstance();
Calendar endTime1 = calendar.getInstance();
int day,month,year,hour,minute;
Date date = new Date();


DateFormat sdf=new SimpleDateFormat("MM/dd/yyyy HH:mm:ss aa");
// SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss aa");
//6/5/2017 12:00:00 AM

try {
date =(Date) sdf.parse("7/14/2017 10:00:00 AM");
} catch (ParseException e) {
e.printStackTrace();
}
day=date.getDate();
month=date.getMonth();
year=date.getYear();
hour=date.getHours();
minute=date.getMinutes();
// startTime1.set(Calendar.YEAR,year);
startTime1.set(Calendar.MONTH,month);
startTime1.set(Calendar.DAY_OF_MONTH, day);
startTime1.set(Calendar.HOUR_OF_DAY, hour);
startTime1.set(Calendar.MINUTE, minute);
endTime1 = startTime1;

eventList.add(new BaseCalendarEvent("First Event: Date 14", "A wonderful
journey!", "LOL",
ContextCompat.getColor(this, R.color.orange_dark), startTime1,
endTime1, true));

try {
date =(Date) sdf.parse("7/15/2017 5:00:00 AM");
} catch (ParseException e) {
e.printStackTrace();
}
day=date.getDate();
month=date.getMonth();
year=date.getYear();
hour=date.getHours();
minute=date.getMinutes();
// startTime1.set(Calendar.YEAR,year);
startTime1.set(Calendar.MONTH,month);
startTime1.set(Calendar.DAY_OF_MONTH, day);
startTime1.set(Calendar.HOUR_OF_DAY, hour);
startTime1.set(Calendar.MINUTE, minute);
endTime1 = startTime1;

/*
BaseCalendarEvent event1 = new BaseCalendarEvent("Thibault travels in
Iceland",
"A wonderful journey!", "Iceland",
ContextCompat.getColor(this, R.color.orange_dark), startTime1, endTime1,
false);
eventList.add(event1);
*/

eventList.add(new BaseCalendarEvent("SEcond Event: Date 15", "A wonderful
journey!", "LOL",
ContextCompat.getColor(this, R.color.orange_dark), startTime1,
endTime1, true));


Calendar startTime3 = Calendar.getInstance();
Calendar endTime3 = Calendar.getInstance();
startTime3.set(Calendar.DAY_OF_MONTH,16);
startTime3.set(Calendar.HOUR_OF_DAY, 16);
startTime3.set(Calendar.MINUTE, 0);
endTime3.set(Calendar.HOUR_OF_DAY, 15);
endTime3.set(Calendar.MINUTE, 0);
DrawableCalendarEvent event3 = new DrawableCalendarEvent("Visit of Harpa",
"", "Dalvík",
ContextCompat.getColor(this, R.color.blue_dark), startTime3,
endTime3, false, android.R.drawable.ic_dialog_info);
eventList.add(event3);
}

最佳答案

在添加事件时创建新的实例

Calendar startTime1 = calendar.getInstance();
Calendar endTime1 = calendar.getInstance();

还捕获异常以便添加更多事件。

关于Android 日历议程 View 事件重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45097503/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com