Hi,大家好,欢迎来到STM32之littlevGL课堂,我们在上节课中学习了预加载控件(lv_preload),本节课带大家学习滑动列表控件,不知道大家还不记得我们之前学习的下拉列表控件,这里我们学习的滑动列表控件其实跟那个差不多类似,废话不多说! 一 有图有真相 二 代码分析 static void roller_event_handler(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_VALUE_CHANGED) { char buf[32]; lv_roller_get_selected_str(obj, buf, sizeof(buf)); printf("Selected month: %s\n", buf); } } void roller_test(void) { lv_obj_t *roller1 = lv_roller_create(lv_scr_act(), NULL); lv_roller_set_options(roller1, "January\n" "February\n" "March\n" "April\n" "May\n" "June\n" "July\n" "August\n" "September\n" "October\n" "November\n" "December", LV_ROLLER_MODE_INIFINITE); lv_roller_set_visible_row_count(roller1, 4); lv_obj_align(roller1, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_event_cb(roller1, roller_event_handler); } lv_roller_set_visible_row_count(roller1, 4); OK,本节课就到这里,大家有没有学会呢?下节课我们学习滑动条控件(lv_slider),我们下节课再见! |