1 #include "../../lv_examples.h"
2 #if LV_USE_MENU && LV_USE_USER_DATA && LV_BUILD_EXAMPLES
3 
lv_example_menu_3(void)4 void lv_example_menu_3(void)
5 {
6     /*Create a menu object*/
7     lv_obj_t * menu = lv_menu_create(lv_scr_act());
8     lv_obj_set_size(menu, lv_disp_get_hor_res(NULL), lv_disp_get_ver_res(NULL));
9     lv_obj_center(menu);
10 
11     /*Modify the header*/
12     lv_obj_t * back_btn = lv_menu_get_main_header_back_btn(menu);
13     lv_obj_t * back_btn_label = lv_label_create(back_btn);
14     lv_label_set_text(back_btn_label, "Back");
15 
16     lv_obj_t * cont;
17     lv_obj_t * label;
18 
19     /*Create sub pages*/
20     lv_obj_t * sub_1_page = lv_menu_page_create(menu, "Page 1");
21 
22     cont = lv_menu_cont_create(sub_1_page);
23     label = lv_label_create(cont);
24     lv_label_set_text(label, "Hello, I am hiding here");
25 
26     lv_obj_t * sub_2_page = lv_menu_page_create(menu, "Page 2");
27 
28     cont = lv_menu_cont_create(sub_2_page);
29     label = lv_label_create(cont);
30     lv_label_set_text(label, "Hello, I am hiding here");
31 
32     lv_obj_t * sub_3_page = lv_menu_page_create(menu, "Page 3");
33 
34     cont = lv_menu_cont_create(sub_3_page);
35     label = lv_label_create(cont);
36     lv_label_set_text(label, "Hello, I am hiding here");
37 
38     /*Create a main page*/
39     lv_obj_t * main_page = lv_menu_page_create(menu, NULL);
40 
41     cont = lv_menu_cont_create(main_page);
42     label = lv_label_create(cont);
43     lv_label_set_text(label, "Item 1 (Click me!)");
44     lv_menu_set_load_page_event(menu, cont, sub_1_page);
45 
46     cont = lv_menu_cont_create(main_page);
47     label = lv_label_create(cont);
48     lv_label_set_text(label, "Item 2 (Click me!)");
49     lv_menu_set_load_page_event(menu, cont, sub_2_page);
50 
51     cont = lv_menu_cont_create(main_page);
52     label = lv_label_create(cont);
53     lv_label_set_text(label, "Item 3 (Click me!)");
54     lv_menu_set_load_page_event(menu, cont, sub_3_page);
55 
56     lv_menu_set_page(menu, main_page);
57 }
58 
59 #endif
60