当前位置:网站首页>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事件
}
运行效果
边栏推荐
- 架构方面的进步
- 一种架构来完成所有任务—Transformer架构正在以一己之力统一AI江湖
- R language uses follow up of epidisplay package The plot function visualizes the longitudinal follow-up map of multiple ID (case) monitoring indicators, and uses stress The col parameter specifies the
- 第十七章 进程内存
- Progress in architecture
- 關於miui12.5 紅米k20pro用au或者povo2出現問題的解决辦法
- Some problems and ideas of data embedding point
- 海外游戏代投需要注意的
- Ws2818m is packaged in cpc8. It is a special circuit for three channel LED drive control. External IC full-color double signal 5v32 lamp programmable LED lamp with outdoor engineering
- [MySQL from introduction to proficiency] [advanced chapter] (IV) MySQL permission management and control
猜你喜欢
Leetcode T48:旋转图像
codeforce:C. Sum of Substrings【边界处理 + 贡献思维 + 灵光一现】
统计php程序运行时间及设置PHP最长运行时间
Test process arrangement (3)
Test evaluation of software testing
Data center concept
WT588F02B-8S(C006_03)单芯片语音ic方案为智能门铃设计降本增效赋能
迅为IMX6Q开发板QT系统移植tinyplay
No servers available for service: xxxx
An overview of 2D human posture estimation
随机推荐
leetcode:6110. 网格图中递增路径的数目【dfs + cache】
nowcoder重排链表
How to package QT and share exe
失败率高达80%,企业数字化转型路上有哪些挑战?
数据湖(十三):Spark与Iceberg整合DDL操作
Digi XBee 3 rf: 4 protocols, 3 packages, 10 major functions
Matters needing attention in overseas game Investment Agency
2022游戏出海实用发行策略
R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据
Learn kernel 3: use GDB to track the kernel call chain
Leetcode t47: full arrangement II
R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用by参数指定分组参数可视化不同分组的点图分布
Leetcode T49: 字母异位词分组
Progress in architecture
STM32F1与STM32CubeIDE编程实例-MAX7219驱动8位7段数码管(基于GPIO)
Incremental ternary subsequence [greedy training]
MySQL的触发器
Detailed explanation of visual studio debugging methods
基于51单片机的超声波测距仪
leetcode:6109. Number of people who know the secret [definition of DP]