当前位置:网站首页>LVGL 8.2 List
LVGL 8.2 List
2022-07-04 14:35:00 【Fairy sword love】
Event callback handler
static lv_obj_t* list1;
static void event_handler(lv_event_t* e)
{
lv_event_code_t code = lv_event_get_code(e); // Get the event code generated by the object
lv_obj_t* obj = lv_event_get_target(e); // Get the object that generated the event
if (code == LV_EVENT_CLICKED) {
// LV_EVENT_CLICKED Event handling
LV_LOG_USER("Clicked: %s", lv_list_get_btn_text(list1, obj)); // Print list The text content corresponding to the click
}
}
establish List
static void lv_example_list_1(void)
{
/*Create a list*/
list1 = lv_list_create(lv_scr_act()); // establish List The control object
lv_obj_set_size(list1, 180, 220); // Set size
lv_obj_center(list1); // centered
/*Add buttons to the list*/
lv_obj_t* btn;
lv_list_add_text(list1, "File"); // add to File Text content
btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "New"); // Add keys
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);// register LV_EVENT_CLICKED event
btn = lv_list_add_btn(list1, LV_SYMBOL_DIRECTORY, "Open");// Add keys
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);// register LV_EVENT_CLICKED event
btn = lv_list_add_btn(list1, LV_SYMBOL_SAVE, "Save");// Add keys
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);// register LV_EVENT_CLICKED event
btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Delete");// Add keys
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);// register LV_EVENT_CLICKED event
btn = lv_list_add_btn(list1, LV_SYMBOL_EDIT, "Edit");// Add keys
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);// register LV_EVENT_CLICKED event
lv_list_add_text(list1, "Connectivity");// Add text content
btn = lv_list_add_btn(list1, LV_SYMBOL_BLUETOOTH, "Bluetooth");// Add keys
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);// register LV_EVENT_CLICKED event
btn = lv_list_add_btn(list1, LV_SYMBOL_GPS, "Navigation");// Add keys
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);// register LV_EVENT_CLICKED event
btn = lv_list_add_btn(list1, LV_SYMBOL_USB, "USB");// Add keys New
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);// register LV_EVENT_CLICKED event
btn = lv_list_add_btn(list1, LV_SYMBOL_BATTERY_FULL, "Battery");// Add keys
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);// register LV_EVENT_CLICKED event
lv_list_add_text(list1, "Exit");// Add text content
btn = lv_list_add_btn(list1, LV_SYMBOL_OK, "Apply");// Add keys
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);// register LV_EVENT_CLICKED event
btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Close");// Add keys
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);// register LV_EVENT_CLICKED event
}
Running effect

边栏推荐
- 【信息检索】链接分析
- 实战解惑 | OpenCV中如何提取不规则ROI区域
- 开发中常见问题总结
- Abnormal value detection using shap value
- leetcode:6109. Number of people who know the secret [definition of DP]
- What is the difference between Bi financial analysis in a narrow sense and financial analysis in a broad sense?
- Docker compose public network deployment redis sentinel mode
- Ml: introduction, principle, use method and detailed introduction of classic cases of snap value
- ML之shap:基于boston波士顿房价回归预测数据集利用shap值对XGBoost模型实现可解释性案例
- R language ggplot2 visualization: gganimate package creates animated graph (GIF) and uses anim_ The save function saves the GIF visual animation
猜你喜欢

NowCoder 反转链表

leetcode:6110. 网格图中递增路径的数目【dfs + cache】

(1)性能调优的标准和做好调优的正确姿势-有性能问题,上HeapDump性能社区!

Red envelope activity design in e-commerce system

STM32F1与STM32CubeIDE编程实例-MAX7219驱动8位7段数码管(基于GPIO)

Transplant tinyplay for imx6q development board QT system

Digi restarts XBee Pro S2C production. Some differences need to be noted

LVGL 8.2 text shadow

Test evaluation of software testing
![[MySQL from introduction to proficiency] [advanced chapter] (IV) MySQL permission management and control](/img/cc/70007321395afe3a9fc6b6032d30aa.png)
[MySQL from introduction to proficiency] [advanced chapter] (IV) MySQL permission management and control
随机推荐
Learn kernel 3: use GDB to track the kernel call chain
Digi XBee 3 rf: 4 protocols, 3 packages, 10 major functions
商業智能BI財務分析,狹義的財務分析和廣義的財務分析有何不同?
Data Lake (13): spark and iceberg integrate DDL operations
nowcoder重排链表
Solutions to the problems of miui12.5 red rice k20pro using Au or povo2
關於miui12.5 紅米k20pro用au或者povo2出現問題的解决辦法
LVGL 8.2 Line wrap, recoloring and scrolling
SqlServer函数,存储过程的创建和使用
C language small commodity management system
Popular framework: the use of glide
Detailed explanation of visual studio debugging methods
Red envelope activity design in e-commerce system
迅为IMX6Q开发板QT系统移植tinyplay
10. (map data) offline terrain data processing (for cesium)
flink sql-client.sh 使用教程
LifeCycle
ML:SHAP值的简介、原理、使用方法、经典案例之详细攻略
MySQL triggers
leetcode:6110. The number of incremental paths in the grid graph [DFS + cache]