1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00
lvgl/examples/widgets/list/lv_example_list_1.c

34 lines
1.3 KiB
C
Raw Normal View History

2021-02-08 09:53:03 +01:00
#include "../../../lvgl.h"
2021-02-14 14:56:34 +01:00
#if LV_USE_LIST && LV_BUILD_EXAMPLES
2021-02-08 09:53:03 +01:00
static void event_handler(lv_obj_t * obj, lv_event_t event)
{
if(event == LV_EVENT_CLICKED) {
2021-02-14 14:56:34 +01:00
LV_LOG_USER("Clicked: %s\n", lv_list_get_btn_text(obj));
2021-02-08 09:53:03 +01:00
}
}
void lv_list_example_1(void)
{
/*Create a list*/
lv_obj_t * list1 = lv_list_create(lv_scr_act());
lv_obj_align(list1, NULL, LV_ALIGN_CENTER, 0, 0);
/*Add buttons to the list*/
lv_list_add_text(list1, "File");
lv_list_add_btn(list1, LV_SYMBOL_FILE, "New", event_handler);
lv_list_add_btn(list1, LV_SYMBOL_DIRECTORY, "Open", event_handler);
lv_list_add_btn(list1, LV_SYMBOL_SAVE, "Save", event_handler);
lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Delete", event_handler);
lv_list_add_btn(list1, LV_SYMBOL_EDIT, "Edit", event_handler);
lv_list_add_text(list1, "Connectivity");
lv_list_add_btn(list1, LV_SYMBOL_BLUETOOTH, "Bluetooth", event_handler);
lv_list_add_btn(list1, LV_SYMBOL_GPS, "Navigation", event_handler);
lv_list_add_btn(list1, LV_SYMBOL_USB, "USB", event_handler);
lv_list_add_btn(list1, LV_SYMBOL_BATTERY_FULL, "Battery", event_handler);
lv_list_add_text(list1, "Exit");
lv_list_add_btn(list1, LV_SYMBOL_OK, "Apply", event_handler);
lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Close", event_handler);
}
#endif