lvgl spinbox(微调框控件)

源代码:

static void spinbox_event_handler(lv_obj_t * obj, lv_event_t event)
{
	if (event == LV_EVENT_VALUE_CHANGED) {
		printf("Value: %d\n", lv_spinbox_get_value(obj));
	}
	else if (event == LV_EVENT_CLICKED) {
		/*For simple test: Click the spinbox to increment its value*/
		lv_spinbox_increment(obj);
	}
}
	//23 微调框控件
	lv_obj_t * spinbox;
	spinbox = lv_spinbox_create(lv_scr_act(), NULL);
	lv_spinbox_set_digit_format(spinbox, 5, 3);
	lv_spinbox_set_step(spinbox, 10);
	lv_spinbox_set_range(spinbox, 0, 100);
	lv_obj_align(spinbox, NULL, LV_ALIGN_IN_LEFT_MID, 0, 60);
	lv_obj_set_event_cb(spinbox, spinbox_event_handler);

效果显示:

おすすめ

転載: blog.csdn.net/chenliang0224/article/details/112914399