Description
I am using the flexbox to dynamically show a list of labels. When I enter this GUI screen, my application code sends the list of text to be displayed. This is converted to labels. When the user exits this GUI screen, the code deletes the group and cleans the screen. However, if re-entered, the same data (text) is sent to the screen. Instead of overwriting the previous flexbox entries as I would prefer, these entries get appended to the bottom. How can I delete the dynamically created labels and overwrite them if the user re-enters the GUI screen?
What MCU/Processor/Board and compiler are you using?
nRF52, custom HW
What LVGL version are you using?
8.2
What do you want to achieve?
A screen being re-entered, and the contents of the flexbox get overwritten
What have you tried so far?
Creating statically defined labels, which get deleted on exit. That didn’t work. I considered moving to the list widget but looking through the list API, I also don’t see a way to remove text or an entry.
Code to reproduce
Here is code that creates the labels:
void Gfx_Info_Set_Entries(struct gfx_info_item_t * items, uint8_t num_items)
{
if(items == NULL) {
OSAL_ASSERT_NO_MSG(false);
return;
}
for(uint8_t i = 0; i < num_items; i++) {
lv_obj_t * label;
label = lv_label_create(s_obj.app_screen.screen);
lv_obj_add_style(label, &haywire_styles.text.small, 0);
lv_label_set_text_fmt(label, "%s", items[i].label_and_value);
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_LEFT, 0);
}
}
And this code block gets called when the screen is exited:
static void _screen_delete_cb(lv_event_t * event)
{
lv_group_del(s_obj.group);
lv_obj_clean(s_obj.app_screen.screen);
}
Thank you.