-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Open
Description
LVGL version
9.5
Platform
all
What happened?
_20260209093826.mp4
How to reproduce?
int32_t row_index = 0;
lv_obj_t * table;
lv_obj_t * add_btn;
lv_obj_t * add_btn_label;
lv_obj_t * sub_btn;
lv_obj_t * sub_btn_label;
static void add_btn_cb(lv_event_t * e)
{
lv_obj_t * obj = lv_event_get_target_obj(e);
lv_event_code_t code = lv_event_get_code(e);
if(code == LV_EVENT_CLICKED)
{
row_index++;
lv_table_set_cell_value_fmt(table, row_index, 0, "test%d", row_index);
lv_table_set_row_count(table,row_index + 1);
}
}
static void sub_btn_cb(lv_event_t * e)
{
lv_obj_t * obj = lv_event_get_target_obj(e);
lv_event_code_t code = lv_event_get_code(e);
if(code == LV_EVENT_CLICKED)
{
row_index--;
if(row_index < 0) row_index = 0;
lv_table_set_row_count(table,row_index + 1);
}
}
void test(void)
{
table = lv_table_create(lv_screen_active());
lv_obj_set_height(table, lv_pct(80));
lv_obj_align(table, LV_ALIGN_TOP_MID, 0, 0);
lv_table_set_cell_value_fmt(table, row_index, 0, "test%d", row_index);
add_btn = lv_button_create(lv_screen_active());
lv_obj_set_size(add_btn, lv_pct(30), lv_pct(15));
lv_obj_align(add_btn, LV_ALIGN_BOTTOM_LEFT, 0, 0);
lv_obj_add_event_cb(add_btn, add_btn_cb, LV_EVENT_CLICKED, NULL);
add_btn_label = lv_label_create(add_btn);
lv_label_set_text(add_btn_label, "add tabel row");
lv_obj_center(add_btn_label);
sub_btn = lv_button_create(lv_screen_active());
lv_obj_set_size(sub_btn, lv_pct(30), lv_pct(15));
lv_obj_align(sub_btn, LV_ALIGN_BOTTOM_RIGHT, 0, 0);
lv_obj_add_event_cb(sub_btn, sub_btn_cb, LV_EVENT_CLICKED, NULL);
sub_btn_label = lv_label_create(sub_btn);
lv_label_set_text(sub_btn_label, "sub tabel row");
lv_obj_center(sub_btn_label);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels