How to update src image button with function

i was make container with image button, but i want change image source when wifi off, but i dont know how to update my container ,
this my code i was using to create container and button

    cont = lv_cont_create(bg_middle, NULL);
    lv_obj_set_auto_realign(cont, true);                    /*Auto realign when the size changes*/
    lv_obj_align_origo(cont, NULL, LV_ALIGN_CENTER, 0, 0);  /*This parametrs will be sued when realigned*/
    lv_cont_set_fit(cont, LV_FIT_TIGHT);
    lv_cont_set_layout(cont, LV_LAYOUT_COLUMN_MID);
//  lv_obj_set_style_local_bg_color(cont, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT,LV_COLOR_WHITE);
     lv_obj_set_size(cont, 150, 150);
     lv_obj_t * imgbtn1 = lv_imgbtn_create(cont, NULL);
     lv_imgbtn_set_src(imgbtn1, LV_BTN_STATE_PRESSED, &reload_icon);
     lv_imgbtn_set_src(imgbtn1, LV_BTN_STATE_RELEASED, &reload_icon);
 
     lv_imgbtn_set_checkable(imgbtn1, true);
     lv_obj_align(imgbtn1, NULL, LV_ALIGN_CENTER, 0, 0);

You can simply call lv_imgbtn_set_src again to set new src when needed.

1 Like

Is there a way to remove an image which previously was set by lv_imgbtn_set_src?

1 Like

Hi @kisvegabor ,

I have the same question than @dohnjoe , once we use :

lv_obj_set_style_bg_img_src ( )

How to remove the background image ( in my case, in a Label). I need to source the image if something exist, but just set text in the default case.

Thanks a lot !

Hi,

you can just use NULL as image source.

1 Like

So obvious…

Thanks a lot !

1 Like