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
|
|
|
}
|
|
|
|
}
|
2021-02-19 18:19:32 +01:00
|
|
|
void lv_example_list_1(void)
|
2021-02-08 09:53:03 +01:00
|
|
|
{
|
|
|
|
/*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
|