当前位置:网站首页>LVGL 8.2 Menu
LVGL 8.2 Menu
2022-07-04 13:07:00 【仙剑情缘】
Simple Menu
static void lv_example_menu_1(void)
{
/*Create a menu object*/
lv_obj_t* menu = lv_menu_create(lv_scr_act()); // 创建菜单对象
lv_obj_set_size(menu, lv_disp_get_hor_res(NULL), lv_disp_get_ver_res(NULL));//设置大小
lv_obj_center(menu); //居中显示
lv_obj_t* cont;
lv_obj_t* label;
/*Create a sub page*/
lv_obj_t* sub_page = lv_menu_page_create(menu, NULL); //创建菜单子页sub_page
cont = lv_menu_cont_create(sub_page); //在sub_page对象上创建cont容器
label = lv_label_create(cont); // 在cont上创建Label
lv_label_set_text(label, "Hello, I am hiding here"); //设置显示内容
/*Create a main page*/
lv_obj_t* main_page = lv_menu_page_create(menu, NULL); //创建菜单子页main_page
cont = lv_menu_cont_create(main_page); //在main_page 对象上创建cont容器
label = lv_label_create(cont); // 在cont上创建Label
lv_label_set_text(label, "Item 1"); //设置显示内容Item 1
cont = lv_menu_cont_create(main_page); //在main_page 对象上创建cont容器
label = lv_label_create(cont); // 在cont上创建Label
lv_label_set_text(label, "Item 2"); //设置显示内容Item 2
cont = lv_menu_cont_create(main_page); //在main_page 对象上创建cont容器
label = lv_label_create(cont); // 在cont上创建Label
lv_label_set_text(label, "Item 3 (Click me!)"); //设置显示内容Item 3 (Click me!)
lv_menu_set_load_page_event(menu, cont, sub_page);//设置菜单menu中cont容器被点击后跳转到sub_page
lv_menu_set_page(menu, main_page);//设置main_page为当前menu的显示页
}
运行效果

item1和item2增加跳转页
static void lv_example_menu_1(void)
{
/*Create a menu object*/
lv_obj_t* menu = lv_menu_create(lv_scr_act());
lv_obj_set_size(menu, lv_disp_get_hor_res(NULL), lv_disp_get_ver_res(NULL));
lv_obj_center(menu);
lv_obj_t* cont;
lv_obj_t* label;
/*Create a sub page*/
lv_obj_t* sub_page = lv_menu_page_create(menu, NULL);
cont = lv_menu_cont_create(sub_page);
label = lv_label_create(cont);
lv_label_set_text(label, "Hello, I am hiding here");
lv_obj_t* sub_page1 = lv_menu_page_create(menu, NULL);
cont = lv_menu_cont_create(sub_page1);
label = lv_label_create(cont);
lv_label_set_text(label, "Hello, I am a sub_page1");
lv_obj_t* sub_page2 = lv_menu_page_create(menu, NULL);
cont = lv_menu_cont_create(sub_page2);
label = lv_label_create(cont);
lv_label_set_text(label, "Hello, I am a sub_page2");
/*Create a main page*/
lv_obj_t* main_page = lv_menu_page_create(menu, NULL);
cont = lv_menu_cont_create(main_page);
label = lv_label_create(cont);
lv_label_set_text(label, "Item 1");
lv_menu_set_load_page_event(menu, cont, sub_page1);
cont = lv_menu_cont_create(main_page);
label = lv_label_create(cont);
lv_label_set_text(label, "Item 2");
lv_menu_set_load_page_event(menu, cont, sub_page2);
cont = lv_menu_cont_create(main_page);
label = lv_label_create(cont);
lv_label_set_text(label, "Item 3 (Click me!)");
lv_menu_set_load_page_event(menu, cont, sub_page);
lv_menu_set_page(menu, main_page);
}
运行效果

边栏推荐
猜你喜欢

Test process arrangement (2)

What is the difference between Bi financial analysis in a narrow sense and financial analysis in a broad sense?

Learn kernel 3: use GDB to track the kernel call chain

How to package QT and share exe

DDD application and practice of domestic hotel transactions -- Code

Excel quickly merges multiple rows of data

Test evaluation of software testing
![[MySQL from introduction to proficiency] [advanced chapter] (V) SQL statement execution process of MySQL](/img/58/a8dbed993921f372d04f7a1ee19679.png)
[MySQL from introduction to proficiency] [advanced chapter] (V) SQL statement execution process of MySQL

leetcode:6110. 网格图中递增路径的数目【dfs + cache】

第十七章 进程内存
随机推荐
尊重他人的行为
Sqlserver functions, creation and use of stored procedures
Fs4059c is a 5V input boost charging 12.6v1.2a. Inputting a small current to three lithium battery charging chips will not pull it dead. The temperature is 60 ° and 1000-1100ma is recommended
使用CLion编译OGLPG-9th-Edition源码
Industrial Internet has greater development potential and more industry scenarios
MySQL之详解索引
ML之shap:基于boston波士顿房价回归预测数据集利用Shap值对LiR线性回归模型实现可解释性案例
GCC【6】- 编译的4个阶段
Solutions to the problems of miui12.5 red rice k20pro using Au or povo2
为什么图片传输要使用base64编码
codeforce:C. Sum of Substrings【边界处理 + 贡献思维 + 灵光一现】
第十六章 字符串本地化和消息字典(二)
Excel快速合并多行数据
潘多拉 IOT 开发板学习(RT-Thread)—— 实验3 按键实验(学习笔记)
The implementation of OSD on rk1126 platform supports color translucency and multi-channel support for Chinese
Leetcode t49: grouping of alphabetic words
Matters needing attention in overseas game Investment Agency
Codeforce:c. sum of substrings
一文概览2D人体姿态估计
Rich text editing: wangeditor tutorial