Important: unclear posts may not receive useful answers.
Before posting
- Get familiar with Markdown to format and structure your post
- Be sure to update lvgl from the latest version from the
master
branch.- Be sure you have checked the FAQ and read the relevant part of the documentation.
- If applicable use the Simulator to eliminate hardware related issues.
Delete this section if you read and applied the mentioned points.
Description
Hi all, I would like to create a row of buttons where only one can be checked at the time. A multi-choice control. To do so, I started understanding how to create a row of buttons.
What MCU/Processor/Board and compiler are you using?
simulator
What LVGL version are you using?
8.3.2
What do you want to achieve?
Multi-selection widget where there are for instance 3 or 4 buttons, but only one can be checked.
What have you tried so far?
The example described here:
https://docs.lvgl.io/8.3/layouts/flex.html
“A simple row and a column layout with flexbox”
Code to reproduce
Starting from the example of a simple row with some buttons, I tried to set one of those checked but
once done, it disappeared.
lv_obj_t * cont_row = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont_row, 300, 75);
lv_obj_align(cont_row, LV_ALIGN_TOP_MID, 0, 5);
lv_obj_set_flex_flow(cont_row, LV_FLEX_FLOW_ROW);
uint32_t i;
for(i = 0; i < 10; i++) {
lv_obj_t * obj;
lv_obj_t * label;
/*Add items to the row*/
obj = lv_btn_create(cont_row);
lv_obj_set_size(obj, 100, LV_PCT(100));
label = lv_label_create(obj);
lv_label_set_text_fmt(label, "Item: %"LV_PRIu32, i);
lv_obj_center(label);
if (i == 2) {
lv_obj_add_flag(obj, LV_STATE_CHECKED);
}
}
Can you make me understanding why this happen please?
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.