How to implement the list dropdown refresh function?如何实现列表下拉刷新功能

Code

The code block(s) should be between ```c and ``` tags:

	lv_obj_t *wifi_cont = lv_win_create(lv_screen_active());
    lv_obj_set_size(wifi_cont, lv_pct(100), lv_pct(100));

    // 2 content layout
    lv_obj_t *content = lv_win_get_content(wifi_cont);
    lv_obj_set_flex_flow(content, LV_FLEX_FLOW_COLUMN);
    lv_obj_set_style_bg_color(content, lv_color_hex(0x000000), LV_STATE_DEFAULT);
    lv_obj_set_style_pad_bottom(content, 0, LV_STATE_DEFAULT);
    lv_obj_set_style_pad_row(content, 10, LV_STATE_DEFAULT);
    lv_obj_set_style_pad_top(content, 0, LV_STATE_DEFAULT);
    lv_obj_add_event_cb(content, wifi_event_handler, LV_EVENT_GESTURE, NULL);
    lv_obj_remove_flag(content, LV_OBJ_FLAG_GESTURE_BUBBLE);

    // 2.1 toggle
    lv_obj_t *mainSwitch = lv_obj_create(content);
    lv_obj_set_size(mainSwitch, lv_pct(100), LV_SIZE_CONTENT);

    lv_obj_t *mainSwitchLabel = lv_label_create(mainSwitch);
    lv_obj_set_align(mainSwitchLabel, LV_ALIGN_LEFT_MID);
    lv_obj_set_style_text_font(mainSwitchLabel, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_label_set_text(mainSwitchLabel, "Wlan");

    toggle = lv_switch_create(mainSwitch);
    lv_obj_set_align(toggle, LV_ALIGN_RIGHT_MID);
    lv_obj_add_state(toggle, LV_STATE_CHECKED);
    lv_obj_add_event_cb(toggle, wifi_event_handler, LV_EVENT_VALUE_CHANGED, NULL);

    // 2.2 nearly networks
    nearlyNetworks = lv_list_create(content);
    lv_obj_set_size(nearlyNetworks, lv_pct(100), LV_SIZE_CONTENT);

    section_label = lv_list_add_text(nearlyNetworks, "Nearly networks");
    lv_obj_set_style_text_font(section_label, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_pad_bottom(section_label, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
	
	for (int i = 0; i < 20; i++)
    {
        lv_list_add_button(nearlyNetworks, LV_SYMBOL_WIFI, "wifi");
    }

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

I would like to inquire about the implementation of some functions, such as loading time-consuming or network requested data. The scenarios that need to be reflected are:

  1. Display loading animation when loading/requesting data;
  2. After the data request is successful, close the loading animation and display the data to the UI;
    How can I achieve it? Create sub threads? Or create a timer task?
    Using sub threads may result in rendering issues, reporting the following error:
    LV_ASSERT_MSG(!disp->rendering_in_progress, “Invalidate area is not allowed during rendering.”);

Hey,

LV_ASSERT_MSG(!disp->rendering_in_progress, “Invalidate area is not allowed during rendering.”);

Can be resolved by calling lv_lock(), lv_unlock() around the LVGL functions in the other thread.

However I think you don’t need a thread or timer for that but you can use create the loader on lv_layer_top() and call lv_obj_add_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE) so that the top layer absorbs the clicks.

When you got the resources just call lv_obj_clean(lv_layer_top()); and lv_obj_remove_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE).