I make screen that includes List.
first, List-items are added to List in setup-screen-routine and this screen is displayed to monitor.
While this screen is displayed, I want to change List-items.
How can I delete List-items and update screen?
Best Regards,
已解决! 转到解答。
After review, the program has been changed as follows.
===================================================================
add A label that includes clickable flag to screen.
when this label is pressed, update List items.
1. clear List items. [ lv_obj_clean(guider_ui.list_1); ]
2. add items to List. [guider_ui.items[i] =lv_list_add_btn(guider_ui.list_1, LV_SYMBOL_**, &f_names[i][0]);]
3. add event to items. [ v_obj_add_event_cb(guider_ui.items[i], **_handler, **, ** ):]
add event send function for changing List items. [ lv_event_send(guider_ui.list_1, LV_EVENT_PRESSES, &***): ]
===================================================================
when I want to change List items from Tasks other than lv_task_handler, I call the function( lv_event_send() ).
it seems to be working properly.
( From other Tasks, directly updating the list items causes a hang-up. so I do this procedure.)
my question is
From any Tasks other than lv_task_handler, How to change the text ,screen, etc.
the function that changes the text, screen and so on is called in event handler.
the event handler is called in lv_task_handler.
I want to change display widgets from another Tasks.
Best Regards.
Hi. Edwin
thanks for your advice.
I tried how to change the items of list.
Therefore, I found the function (lv_obj_clean()). and I make the code that achieve this.
// clear the children of list
lv_obj_clean(guider_ui.file_access_F_LIST);
// add new items(array) to list and set style to items
for ( i=0; i<file_count, i++ ) {
guider_ui.items[i] = lv_list_ass_btn(giuder_ui.file_access_F_LIST, LV_SYMBOL_***, &file_names[i][0]);
lv_obj_add_style(giuder_ui.items[i], &style_********, LV_PART_MAIN | LV_STATE_DEFAULT);
}
// add Event Handler to List-items
for ( i=0; i<file_count, i++ ) {
lv_obj_add_event_cb(giuder_ui.items[i], ***_handler, LV_EVENT_ALL, ***);
}
it seems to be working correctly, but I wonder if the management of work memory is done correctly in these processes.
How can I check this?
Best Regards,
Hi @syoshida,
What you are trying to achieve can be done by using custom code.
Sadly, it wasn't until LVGL v9 that they added a "lv_list_set_button_text()" function to set a list item to a specific text. In v8.3, which GUI Guider 1.7.0 currently uses, this function is not yet present. This means that your custom code has to get to the pointer of the text label of the button in the list, manually. Here is an illustrative custom code I wrote on how to achieve this:
// Get pointer of the first item in list
lv_obj_t * list_item0 = lv_obj_get_child(guider_ui.screen_list_1, 0);
// Get the text of this item (1 for text, 0 for icon)
lv_obj_t * item0_text = lv_obj_get_child(list_item0, 1);
// Change the value of this text pointer
lv_label_set_text(item0_text, "New Text!");
This code was inspired from the following LVGL forum post: How to change list's element? - How-to - LVGL Forum
Just add this code to an event that you wish to use as trigger to change the list items as the video of this community post shows, and you should be able to achieve what you are looking for.
BR,
Edwin.
After review, the program has been changed as follows.
===================================================================
add A label that includes clickable flag to screen.
when this label is pressed, update List items.
1. clear List items. [ lv_obj_clean(guider_ui.list_1); ]
2. add items to List. [guider_ui.items[i] =lv_list_add_btn(guider_ui.list_1, LV_SYMBOL_**, &f_names[i][0]);]
3. add event to items. [ v_obj_add_event_cb(guider_ui.items[i], **_handler, **, ** ):]
add event send function for changing List items. [ lv_event_send(guider_ui.list_1, LV_EVENT_PRESSES, &***): ]
===================================================================
when I want to change List items from Tasks other than lv_task_handler, I call the function( lv_event_send() ).
it seems to be working properly.
( From other Tasks, directly updating the list items causes a hang-up. so I do this procedure.)
my question is
From any Tasks other than lv_task_handler, How to change the text ,screen, etc.
the function that changes the text, screen and so on is called in event handler.
the event handler is called in lv_task_handler.
I want to change display widgets from another Tasks.
Best Regards.