当前位置:网站首页>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事件
}
运行效果
边栏推荐
- C # WPF realizes the real-time screen capture function of screen capture box
- DDD application and practice of domestic hotel transactions -- Code
- 尊重他人的行为
- Ruiji takeout notes
- R language dplyr package summary_ If function calculates the mean and median of all numerical data columns in dataframe data, and summarizes all numerical variables based on conditions
- 如何游戏出海代运营、游戏出海代投
- 卷积神经网络经典论文集合(深度学习分类篇)
- Leetcode T48: rotating images
- Leetcode T47: 全排列II
- 利用Shap值进行异常值检测
猜你喜欢
Map of mL: Based on Boston house price regression prediction data set, an interpretable case of xgboost model using map value
Leetcode T48:旋转图像
Oppo find N2 product form first exposure: supplement all short boards
Digi restarts XBee Pro S2C production. Some differences need to be noted
去除重复字母[贪心+单调栈(用数组+len来维持单调序列)]
实战解惑 | OpenCV中如何提取不规则ROI区域
Incremental ternary subsequence [greedy training]
Digi重启XBee-Pro S2C生产,有些差别需要注意
Supprimer les lettres dupliquées [avidité + pile monotone (maintenir la séquence monotone avec un tableau + Len)]
Data Lake (13): spark and iceberg integrate DDL operations
随机推荐
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
GCC【6】- 编译的4个阶段
R语言使用lattice包中的bwplot函数可视化箱图(box plot)、par.settings参数自定义主题模式
C# wpf 实现截屏框实时截屏功能
Codeforce:c. sum of substrings
Count the running time of PHP program and set the maximum running time of PHP
The failure rate is as high as 80%. What are the challenges on the way of enterprise digital transformation?
R语言dplyr包summarise_if函数计算dataframe数据中所有数值数据列的均值和中位数、基于条件进行数据汇总分析(Summarize all Numeric Variables)
使用CLion编译OGLPG-9th-Edition源码
商業智能BI財務分析,狹義的財務分析和廣義的財務分析有何不同?
电商系统中红包活动设计
R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graph, and uses the by parameter to specify the groupin
One architecture to complete all tasks - transformer architecture is unifying the AI Jianghu on its own
AI与生命科学
Respect others' behavior
MySQL的存储过程练习题
Nowcoder rearrange linked list
Chapter 17 process memory
ML之shap:基于boston波士顿房价回归预测数据集利用shap值对XGBoost模型实现可解释性案例
DDD application and practice of domestic hotel transactions -- Code