如何在alamkanak周视图中显示标题

时间:2016-01-26 04:44:06

标签: java android android-library android-calendar

我在我的应用中使用alam kanak week view。我希望在日历中显示标题。请帮忙!

//我的代码

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();
    Calendar endTime = (Calendar) startTime.clone();
    WeekViewEvent event;

    List<ScheduleModel> contacts = db.getAllSchedule();
    for (int i = 1; i <= 4; i++) {
            for (ScheduleModel cn : contacts) {

                startTime = Calendar.getInstance();
                startTime.set(Calendar.HOUR_OF_DAY, cn.getStart_hour());
                startTime.set(Calendar.MINUTE, cn.getStart_minute());
                startTime.set(Calendar.DAY_OF_WEEK, cn.getDay() + 1);                    
                startTime.set(Calendar.MONTH, newMonth - 1);                    
                startTime.set(Calendar.YEAR, newYear);
                endTime = (Calendar) startTime.clone();
                endTime.set(Calendar.HOUR_OF_DAY, cn.getEnd_hour());
                endTime.set(Calendar.MINUTE, cn.getEnd_minute());
                event = new WeekViewEvent(5, getEventTitle(startTime, cn.getSubject()), startTime, endTime);

                event.setColor(Color.parseColor(cn.getBg_color()));

                events.add(event);            
        }
    }
    return events;
}

    private String getEventTitle(Calendar time, String subject) {
    return String.format("Event %s of %02d:%02d %s/%d", subject, time.get(Calendar.HOUR_OF_DAY), time.get(Calendar.MINUTE), time.get(Calendar.MONTH) + 1, time.get(Calendar.DAY_OF_MONTH));
}

照片:

my Screenshot aplication

0 个答案:

没有答案