calendar for litter vGL

  • 日期选择回调函数

void calendar_event_handler(lv_obj_t* obj, lv_event_t event) 
{
    if (event == LV_EVENT_CLICKED)
    {
        lv_calendar_date_t* date = lv_calendar_get_pressed_date(obj);
        if (date)
        {
            lv_calendar_set_today_date(obj, date);
        }
    }
}
  • 日历实现


void lv_ex_calendar_1(void) 
{
    lv_obj_t* calendar = lv_calendar_create(lv_scr_act(), NULL);
    lv_obj_set_size(calendar, 230, 230);
    lv_obj_align(calendar, NULL,LV_ALIGN_CENTER, 0, 0);
    lv_obj_set_event_cb(calendar, calendar_event_handler);

    /*Set the today*/
    lv_calendar_date_t today;
    today.year = 2020;
    today.month = 2;
    today.day = 18;

    lv_calendar_set_today_date(calendar, &today);
    lv_calendar_set_showed_date(calendar, &today);

    /*Highlight some days*/
    static lv_calendar_date_t highlight_days[3];
    highlight_days[0].year = 2020;
    highlight_days[0].month = 2;
    highlight_days[0].day = 6;

    highlight_days[1].year = 2020;
    highlight_days[1].month = 2;
    highlight_days[1].day = 15;

    highlight_days[2].year = 2020;
    highlight_days[2].month = 2;
    highlight_days[2].day = 26;

    lv_calendar_set_highlighted_dates(calendar, &highlight_days,3);
}
  • call the lv_ex_calendar_1 function in main,compile and run this exmple.

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值