/**
* Checkboxes as radio buttons
*/staticvoidlv_example_checkbox_2(void){/* The idea is to enable `LV_OBJ_FLAG_EVENT_BUBBLE` on checkboxes and process the
* `LV_EVENT_CLICKED` on the container.
* A variable is passed as event user data where the index of the active
* radiobutton is saved */lv_style_init(&style_radio);//初时化style_radiolv_style_set_radius(&style_radio, LV_RADIUS_CIRCLE);//设置倒角为圆形lv_style_init(&style_radio_chk);//初时化style_radio_chklv_style_set_bg_img_src(&style_radio_chk,NULL);//设置背景图标资源为NULLuint32_t i;char buf[32];lv_obj_t* cont1 =lv_obj_create(lv_scr_act());//创建对象用于layoutlv_obj_set_flex_flow(cont1, LV_FLEX_FLOW_COLUMN);//设置布局为LV_FLEX_FLOW_COLUMN方式lv_obj_set_size(cont1,lv_pct(40),lv_pct(80));//设置大小lv_obj_add_event_cb(cont1, radio_event_handler, LV_EVENT_CLICKED,&active_index_1);// 添加LV_EVENT_CLICKED事件,用户自定义数据为active_index_1for(i =0; i <5; i++){lv_snprintf(buf,sizeof(buf),"A %d",(int)i +1);radiobutton_create(cont1, buf);//共创建5个radio按键}/*Make the first checkbox checked*/lv_obj_add_state(lv_obj_get_child(cont1,0), LV_STATE_CHECKED);//选中第1个radiolv_obj_t* cont2 =lv_obj_create(lv_scr_act());//创建对象用于layoutlv_obj_set_flex_flow(cont2, LV_FLEX_FLOW_COLUMN);//设置布局为LV_FLEX_FLOW_COLUMN方式lv_obj_set_size(cont2,lv_pct(40),lv_pct(80));//设置大小lv_obj_set_x(cont2,lv_pct(50));//设置cont2布局x位置为屏慕的50%处lv_obj_add_event_cb(cont2, radio_event_handler, LV_EVENT_CLICKED,&active_index_2);// 添加LV_EVENT_CLICKED事件,用户自定义数据为active_index_2for(i =0; i <3; i++){lv_snprintf(buf,sizeof(buf),"B %d",(int)i +1);radiobutton_create(cont2, buf);//共创建3个radio按键}/*Make the first checkbox checked*/lv_obj_add_state(lv_obj_get_child(cont2,0), LV_STATE_CHECKED);//选中第1个radio}