mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-21 06:53:01 +08:00
36 lines
980 B
C
36 lines
980 B
C
|
#include "../../../lvgl.h"
|
||
|
#include <stdio.h>
|
||
|
#if LV_USE_DROPDOWN
|
||
|
|
||
|
|
||
|
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||
|
{
|
||
|
if(event == LV_EVENT_VALUE_CHANGED) {
|
||
|
char buf[32];
|
||
|
lv_dropdown_get_selected_str(obj, buf, sizeof(buf));
|
||
|
printf("Option: %s\n", buf);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void lv_example_dropdown_1(void)
|
||
|
{
|
||
|
|
||
|
/*Create a normal drop down list*/
|
||
|
lv_obj_t * dd = lv_dropdown_create(lv_scr_act(), NULL);
|
||
|
lv_dropdown_set_options(dd, "Apple\n"
|
||
|
"Banana\n"
|
||
|
"Orange\n"
|
||
|
"Cherry\n"
|
||
|
"Grape\n"
|
||
|
"Raspberry\n"
|
||
|
"Melon\n"
|
||
|
"Orange\n"
|
||
|
"Lemon\n"
|
||
|
"Nuts");
|
||
|
|
||
|
lv_obj_align(dd, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);
|
||
|
lv_obj_add_event_cb(dd, event_handler, NULL);
|
||
|
}
|
||
|
|
||
|
#endif
|