当前位置:网站首页>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事件
}
运行效果

边栏推荐
- LiveData
- R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用by参数指定分组参数可视化不同分组的点图分布
- PyTorch的自动求导机制详细解析,PyTorch的核心魔法
- Test process arrangement (2)
- How to operate and invest games on behalf of others at sea
- 商业智能BI财务分析,狭义的财务分析和广义的财务分析有何不同?
- nowcoder重排链表
- 第十六章 字符串本地化和消息字典(二)
- Map of mL: Based on Boston house price regression prediction data set, an interpretable case is realized by using the map value to the LIR linear regression model
- 数据仓库面试问题准备
猜你喜欢

Rich text editing: wangeditor tutorial

Detailed index of MySQL

vscode 常用插件汇总
![去除重复字母[贪心+单调栈(用数组+len来维持单调序列)]](/img/af/a1dcba6f45eb4ccc668cd04a662e9c.png)
去除重复字母[贪心+单调栈(用数组+len来维持单调序列)]

实时数据仓库

C # WPF realizes the real-time screen capture function of screen capture box

Detailed analysis of pytorch's automatic derivation mechanism, pytorch's core magic

潘多拉 IOT 开发板学习(RT-Thread)—— 实验3 按键实验(学习笔记)

按照功能对Boost库进行分类

为什么图片传输要使用base64编码
随机推荐
redis 日常笔记
Leetcode T48: rotating images
R语言使用dplyr包的group_by函数和summarise函数基于分组变量计算目标变量的均值、标准差
The implementation of OSD on rk1126 platform supports color translucency and multi-channel support for Chinese
Compile oglpg-9th-edition source code with clion
Incremental ternary subsequence [greedy training]
ML:SHAP值的简介、原理、使用方法、经典案例之详细攻略
MySQL的触发器
海外游戏代投需要注意的
關於miui12.5 紅米k20pro用au或者povo2出現問題的解决辦法
opencv3.2 和opencv2.4安装
WT588F02B-8S(C006_03)单芯片语音ic方案为智能门铃设计降本增效赋能
Xcode 异常图片导致ipa包增大问题
Solutions aux problèmes d'utilisation de l'au ou du povo 2 dans le riz rouge k20pro MIUI 12.5
Count the running time of PHP program and set the maximum running time of PHP
R language uses bwplot function in lattice package to visualize box plot and par Settings parameter custom theme mode
商業智能BI財務分析,狹義的財務分析和廣義的財務分析有何不同?
Talk about 10 tips to ensure thread safety
第十七章 进程内存
No servers available for service: xxxx