当前位置:网站首页>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);
}
运行效果
边栏推荐
- 【信息检索】链接分析
- Talk about 10 tips to ensure thread safety
- R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用by参数指定分组参数可视化不同分组的点图分布
- (1)性能调优的标准和做好调优的正确姿势-有性能问题,上HeapDump性能社区!
- GCC【6】- 编译的4个阶段
- Sqlserver functions, creation and use of stored procedures
- 按照功能对Boost库进行分类
- R language ggplot2 visualization: gganimate package creates animated graph (GIF) and uses anim_ The save function saves the GIF visual animation
- Digi restarts XBee Pro S2C production. Some differences need to be noted
- 游戏出海,全球化运营
猜你喜欢
Digi restarts XBee Pro S2C production. Some differences need to be noted
Supprimer les lettres dupliquées [avidité + pile monotone (maintenir la séquence monotone avec un tableau + Len)]
nowcoder重排链表
Detailed index of MySQL
C# wpf 实现截屏框实时截屏功能
Use of tiledlayout function in MATLAB
No servers available for service: xxxx
Excel快速合并多行数据
商業智能BI財務分析,狹義的財務分析和廣義的財務分析有何不同?
What is the difference between Bi financial analysis in a narrow sense and financial analysis in a broad sense?
随机推荐
Map of mL: Based on Boston house price regression prediction data set, an interpretable case of xgboost model using map value
使用CLion编译OGLPG-9th-Edition源码
【算法leetcode】面试题 04.03. 特定深度节点链表(多语言实现)
Learn kernel 3: use GDB to track the kernel call chain
C # WPF realizes the real-time screen capture function of screen capture box
Rich text editing: wangeditor tutorial
Count the running time of PHP program and set the maximum running time of PHP
R language uses the mutation function of dplyr package to standardize the specified data column (using mean function and SD function), and calculates the grouping mean of the standardized target varia
R语言dplyr包summarise_if函数计算dataframe数据中所有数值数据列的均值和中位数、基于条件进行数据汇总分析(Summarize all Numeric Variables)
redis 日常笔记
Digi XBee 3 rf: 4 protocols, 3 packages, 10 major functions
Oppo find N2 product form first exposure: supplement all short boards
利用Shap值进行异常值检测
软件测试之测试评估
Sqlserver functions, creation and use of stored procedures
Vscode common plug-ins summary
Opencv3.2 and opencv2.4 installation
Detailed explanation of visual studio debugging methods
ML之shap:基于boston波士顿房价回归预测数据集利用Shap值对LiR线性回归模型实现可解释性案例
Visual Studio调试方式详解