fix(examples): update the get started examples

This commit is contained in:
Gabor Kiss-Vamosi
2021-02-16 20:41:11 +01:00
parent 4c1b18527b
commit f04dc72c4a
3 changed files with 103 additions and 116 deletions

View File

@@ -10,21 +10,23 @@ static void btn_event_cb(lv_obj_t * btn, lv_event_t event)
/*Get the first child of the button which is the label and change its text*/
lv_obj_t * label = lv_obj_get_child(btn, 0);
lv_label_set_text_fmt(label, "Button: %d", cnt);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
}
/**
* Create a button with a label and react on Click event.
* Create a button with a label and react on click event.
*/
void lv_example_get_started_1(void)
{
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button the current screen*/
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 120, 50); /*Set its size*/
lv_obj_add_event_cb(btn, btn_event_cb, NULL); /*Assign a callback to the button*/
lv_obj_add_event_cb(btn, btn_event_cb, NULL); /*Assign a callback to the button*/
lv_obj_t * label = lv_label_create(btn, NULL); /*Add a label to the button*/
lv_label_set_text(label, "Button"); /*Set the labels text*/
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
#endif