当前位置:网站首页>LVGL 8.2 List
LVGL 8.2 List
2022-07-04 13:07:00 【仙剑情缘】
事件回调处理函数
static lv_obj_t* list1;
static void event_handler(lv_event_t* e)
{
lv_event_code_t code = lv_event_get_code(e); // 获取对象产生的事件码
lv_obj_t* obj = lv_event_get_target(e); // 获取产生事件的对象
if (code == LV_EVENT_CLICKED) {
// LV_EVENT_CLICKED事件处理
LV_LOG_USER("Clicked: %s", lv_list_get_btn_text(list1, obj)); //打印list对应点击的文本内容
}
}
创建List
static void lv_example_list_1(void)
{
/*Create a list*/
list1 = lv_list_create(lv_scr_act()); //创建List控件对象
lv_obj_set_size(list1, 180, 220); // 设置大小
lv_obj_center(list1); // 居中显示
/*Add buttons to the list*/
lv_obj_t* btn;
lv_list_add_text(list1, "File"); // 添加File文本内容
btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "New"); //添加按键
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);//注册LV_EVENT_CLICKED事件
btn = lv_list_add_btn(list1, LV_SYMBOL_DIRECTORY, "Open");//添加按键
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);//注册LV_EVENT_CLICKED事件
btn = lv_list_add_btn(list1, LV_SYMBOL_SAVE, "Save");//添加按键
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);//注册LV_EVENT_CLICKED事件
btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Delete");//添加按键
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);//注册LV_EVENT_CLICKED事件
btn = lv_list_add_btn(list1, LV_SYMBOL_EDIT, "Edit");//添加按键
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);//注册LV_EVENT_CLICKED事件
lv_list_add_text(list1, "Connectivity");// 添加文本内容
btn = lv_list_add_btn(list1, LV_SYMBOL_BLUETOOTH, "Bluetooth");//添加按键
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);//注册LV_EVENT_CLICKED事件
btn = lv_list_add_btn(list1, LV_SYMBOL_GPS, "Navigation");//添加按键
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);//注册LV_EVENT_CLICKED事件
btn = lv_list_add_btn(list1, LV_SYMBOL_USB, "USB");//添加按键New
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);//注册LV_EVENT_CLICKED事件
btn = lv_list_add_btn(list1, LV_SYMBOL_BATTERY_FULL, "Battery");//添加按键
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);//注册LV_EVENT_CLICKED事件
lv_list_add_text(list1, "Exit");// 添加文本内容
btn = lv_list_add_btn(list1, LV_SYMBOL_OK, "Apply");//添加按键
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);//注册LV_EVENT_CLICKED事件
btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Close");//添加按键
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);//注册LV_EVENT_CLICKED事件
}
运行效果
边栏推荐
- Talk about 10 tips to ensure thread safety
- Supprimer les lettres dupliquées [avidité + pile monotone (maintenir la séquence monotone avec un tableau + Len)]
- gin集成支付宝支付
- RK1126平台OSD的实现支持颜色半透明度多通道支持中文
- flink sql-client.sh 使用教程
- Visual Studio调试方式详解
- ML之shap:基于boston波士顿房价回归预测数据集利用Shap值对LiR线性回归模型实现可解释性案例
- Real time data warehouse
- The game goes to sea and operates globally
- Solutions to the problems of miui12.5 red rice k20pro using Au or povo2
猜你喜欢
Visual Studio调试方式详解
What is the difference between Bi financial analysis in a narrow sense and financial analysis in a broad sense?
STM32F1与STM32CubeIDE编程实例-MAX7219驱动8位7段数码管(基于GPIO)
(1)性能调优的标准和做好调优的正确姿势-有性能问题,上HeapDump性能社区!
Oppo find N2 product form first exposure: supplement all short boards
Excel快速合并多行数据
Test evaluation of software testing
Scratch Castle Adventure Electronic Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
flink sql-client. SH tutorial
Leetcode 61: 旋转链表
随机推荐
R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用by参数指定分组参数可视化不同分组的点图分布
Leetcode t47: full arrangement II
卷积神经网络经典论文集合(深度学习分类篇)
[cloud native] how can I compete with this database?
聊聊保证线程安全的 10 个小技巧
统计php程序运行时间及设置PHP最长运行时间
Digi重启XBee-Pro S2C生产,有些差别需要注意
Data center concept
關於miui12.5 紅米k20pro用au或者povo2出現問題的解决辦法
LifeCycle
R language uses the mutation function of dplyr package to standardize the specified data column (using mean function and SD function), and calculates the grouping mean of the standardized target varia
MySQL stored procedure exercise
The implementation of OSD on rk1126 platform supports color translucency and multi-channel support for Chinese
AI and Life Sciences
Practical puzzle solving | how to extract irregular ROI regions in opencv
PyTorch的自动求导机制详细解析,PyTorch的核心魔法
vscode 常用插件汇总
Sqlserver functions, creation and use of stored procedures
R language ggplot2 visualization: gganimate package creates animated graph (GIF) and uses anim_ The save function saves the GIF visual animation
Excel快速合并多行数据