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

边栏推荐
- Detailed explanation of visual studio debugging methods
- Leetcode t47: full arrangement II
- 按照功能对Boost库进行分类
- MySQL的存储过程练习题
- 海外游戏代投需要注意的
- AI and Life Sciences
- 尊重他人的行为
- Use of arouter
- The failure rate is as high as 80%. What are the challenges on the way of enterprise digital transformation?
- R语言使用dplyr包的mutate函数对指定数据列进行标准化处理(使用mean函数和sd函数)并基于分组变量计算标准化后的目标变量的分组均值
猜你喜欢

Innovation and development of independent industrial software
![Supprimer les lettres dupliquées [avidité + pile monotone (maintenir la séquence monotone avec un tableau + Len)]](/img/af/a1dcba6f45eb4ccc668cd04a662e9c.png)
Supprimer les lettres dupliquées [avidité + pile monotone (maintenir la séquence monotone avec un tableau + Len)]

No servers available for service: xxxx

nowcoder重排链表

数据仓库面试问题准备

【信息检索】分类和聚类的实验

商業智能BI財務分析,狹義的財務分析和廣義的財務分析有何不同?

10.(地图数据篇)离线地形数据处理(供Cesium使用)

Ruiji takeout notes

sql优化之explain
随机推荐
Leetcode T47: 全排列II
实战解惑 | OpenCV中如何提取不规则ROI区域
软件测试之测试评估
Leetcode T48: rotating images
R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据
How to package QT and share exe
Excel快速合并多行数据
flink sql-client.sh 使用教程
sql优化之查询优化器
商业智能BI财务分析,狭义的财务分析和广义的财务分析有何不同?
如何游戏出海代运营、游戏出海代投
Scratch Castle Adventure Electronic Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
scratch古堡历险记 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
统计php程序运行时间及设置PHP最长运行时间
The failure rate is as high as 80%. What are the challenges on the way of enterprise digital transformation?
How to operate and invest games on behalf of others at sea
C# wpf 实现截屏框实时截屏功能
Test process arrangement (2)
DDD application and practice of domestic hotel transactions -- Code
R language ggplot2 visualization: gganimate package creates dynamic line graph animation (GIF) and uses transition_ The reveal function displays data step by step along a given dimension in the animat