当前位置:网站首页>LVGL 8.2 Simple Drop down list
LVGL 8.2 Simple Drop down list
2022-06-30 10:08:00 【仙剑情缘】
事件处理回调函数
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_VALUE_CHANGED) {
// 处理值已改变事件
char buf[32];
lv_dropdown_get_selected_str(obj, buf, sizeof(buf)); // 获取选中对象的文本内容
LV_LOG_USER("Option: %s", buf); // 打印文本内容
}
}
创建dropdown
static void lv_example_dropdown_1(void)
{
/*Create a normal drop down list*/
lv_obj_t* dd = lv_dropdown_create(lv_scr_act()); //创建dropdown对象
lv_dropdown_set_options(dd, "Apple\n"
"Banana\n"
"Orange\n"
"Cherry\n"
"Grape\n"
"Raspberry\n"
"Melon\n"
"Orange\n"
"Lemon\n"
"Nuts"); // 设置下拉列表选项内容
lv_obj_align(dd, LV_ALIGN_TOP_MID, 0, 20); //LV_ALIGN_TOP_MID方式对齐
lv_obj_add_event_cb(dd, event_handler, LV_EVENT_ALL, NULL); // 添加所有事件
}
运行效果

边栏推荐
- Anhui "requirements for design depth of Hefei fabricated building construction drawing review" was printed and distributed; Hebei Hengshui city adjusts the pre-sale license standard for prefabricated
- sCrypt 中的 ECDSA 签名验证
- Dyson design award, changing the world with sustainable design
- Leetcode question brushing (III) -- binary search (go Implementation)
- WGet -- 404 not found due to spaces in URL
- mysql数据库基础:存储过程和函数
- Using LVM to resize partitions
- ArcGIS Pro scripting tool (5) - delete duplicates after sorting
- Pytorch Notebook. Nn. Batchnorm1d
- Gd32 RT thread PWM drive function
猜你喜欢

微信推出图片大爆炸功能;苹果自研 5G 芯片或已失败;微软解决导致 Edge 停止响应的 bug|极客头条...

文件共享服务器

Yixian e-commerce released its first quarterly report: adhere to R & D and brand investment to achieve sustainable and high-quality development

数学知识复习:第二型曲线积分
[email protected]语音模块+stm32+nfc"/>技能梳理[email protected]语音模块+stm32+nfc

今晚19:00知识赋能第2期直播丨OpenHarmony智能家居项目之控制面板界面设计

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

CSDN博客运营团队2022年H1总结

从0使用keil5软件仿真调试GD32F305

Matplotlib notes: contour & Contour
随机推荐
CSDN blog operation team 2022 H1 summary
ArcGIS Pro脚本工具(5)——排序后删除重复项
Implementation of monitor program with assembly language
Pytorch Notebook. Nn. Batchnorm1d
透过华为军团看科技之变(五):智慧园区
js常见问题
scratch绘制正方形 电子学会图形化编程scratch等级考试二级真题和答案解析2022年6月
Dyson design award, changing the world with sustainable design
Implementation of iterative method for linear equations
ArcGIS Pro脚本工具(6)——修复CAD图层数据源
Mysql database foundation: TCL transaction control language
[rust weekly database] num bigint - large integer
How to deploy deflationary combustion destruction contract code in BSC chain_ Deploy dividend and marketing wallet contract code
Getting started with X86 - take over bare metal control
Dow Jones Industrial Average
技能梳理[email protected]体感机械臂
Collectors.toMap应用
Gd32 RT thread ota/bootloader driver function
mysql数据库基础:约束、标识列
Gd32 RT thread flash driver function