当前位置:网站首页>LVGL 8.2 menu from a drop-down list
LVGL 8.2 menu from a drop-down list
2022-06-30 10:08:00 【仙剑情缘】
事件处理回调函数
static void event_cb(lv_event_t* e)
{
lv_obj_t* dropdown = lv_event_get_target(e); // 获取产生事件的对象
char buf[64];
lv_dropdown_get_selected_str(dropdown, buf, sizeof(buf)); //获取dropdown对象选择的内容
LV_LOG_USER("'%s' is selected", buf); // 打印选择的内容
}
Create a menu from a drop-down list
/** * Create a menu from a drop-down list and show some drop-down list features and styling */
static void lv_example_dropdown_3(void)
{
/*Create a drop down list*/
lv_obj_t* dropdown = lv_dropdown_create(lv_scr_act()); // 创建dropdown对象
lv_obj_align(dropdown, LV_ALIGN_TOP_LEFT, 10, 10); //LV_ALIGN_TOP_LEFT方式对齐
lv_dropdown_set_options(dropdown, "New project\n"
"New file\n"
"Save\n"
"Save as ...\n"
"Open project\n"
"Recent projects\n"
"Preferences\n"
"Exit"); // 设置选项内容
/*Set a fixed text to display on the button of the drop-down list*/
lv_dropdown_set_text(dropdown, "Menu"); // 设置固定文本Menu
/*Use a custom image as down icon and flip it when the list is opened*/
LV_IMG_DECLARE(img_caret_down) //img_caret_down图片资源声明
lv_dropdown_set_symbol(dropdown, &img_caret_down); // 设置dropdown符号
lv_obj_set_style_transform_angle(dropdown, 1800, LV_PART_INDICATOR | LV_STATE_CHECKED); // LV_PART_INDICATOR 和 LV_STATE_CHECKED属性时图片旋转180度
/*In a menu we don't need to show the last clicked item*/
lv_dropdown_set_selected_highlight(dropdown, false); //选中项关闭高亮显示
lv_obj_add_event_cb(dropdown, event_cb, LV_EVENT_VALUE_CHANGED, NULL);//dropdown添加LV_EVENT_VALUE_CHANGED画件
}
运行效果

lv_dropdown_set_selected_highlight函数打开选中项高亮显示
lv_dropdown_set_selected_highlight(dropdown, true); // 设成true打开高亮
运行效果

边栏推荐
- 那个程序员,被打了。
- Gd32 RT thread RTC driver function
- Didi open source agile test case management platform!
- Viewing technological changes through Huawei Corps (V): smart Park
- Mysql database foundation: views and variables
- 智能DNA分子纳米机器人模型来了
- R语言plotly可视化:使用plotly可视化多分类模型的预测置信度、模型在2D网格中每个数据点预测的置信度、置信度定义为在某一点上最高分与其他类别得分之和之间的差值
- 软件测试工程师面试基础题(应届生和测试小菜必备)最基础的面试题
- 安徽《合肥市装配式建筑施工图审查设计深度要求》印发;河北衡水市调整装配式建筑预售许可标准
- Leetcode question brushing (II) -- sorting (go Implementation)
猜你喜欢

ArcGIS Pro脚本工具(5)——排序后删除重复项
[email protected]+阿里云+nbiot+dht11+bh1750+土壤湿度传感器+oled"/>技能梳理[email protected]+阿里云+nbiot+dht11+bh1750+土壤湿度传感器+oled

同事的接口文档我每次看着就头大,毛病多多。。。

CSDN blog operation team 2022 H1 summary

Robotframework learning notes: environment installation and robotframework browser plug-in installation

matplotlib 笔记: contourf & contour

Matplotlib notes: contour & Contour

Auto Seg-Loss: 自动损失函数设计

The performance of arm's new CPU has been improved by 22%, up to 12 cores can be combined, and the GPU is first equipped with hardware optical tracking. Netizen: the gap with apple is growing
[email protected]语音模块+stm32+nfc"/>技能梳理[email protected]语音模块+stm32+nfc
随机推荐
ArcGIS Pro脚本工具(5)——排序后删除重复项
Kernel linked list (general linked list) "list.h" simple version and individual comments
Skill combing [email protected] voice module +stm32+nfc
js常见问题
mysql数据库基础:TCL事务控制语言
LVGL 8.2 Image styling and offset
【Rust日报】2021-01-23 几个新库发布
WGet -- 404 not found due to spaces in URL
Foster design method
Input a decimal data, convert to 8, using the sequence stack
Leetcode question brushing (III) -- binary search (go Implementation)
pytorch 筆記 torch.nn.BatchNorm1d
IPhone address book import into Excel
小程序中读取腾讯文档的表格数据
[deep learning] common methods for deep learning to detect small targets
断路器HystrixCircuitBreaker
& and - > priority
sCrypt 中的 ECDSA 签名验证
Criu enables hot migration
Mysql database foundation: constraint and identification columns