Hi everyone,
In the button of list case, how can I modify the ON/OFF status of the label?
Emm...I am sorry that i am one of the leeches in LVGL forum and no contribute at all...
Best regards
Lucas
Hi everyone,
In the button of list case, how can I modify the ON/OFF status of the label?
Emm...I am sorry that i am one of the leeches in LVGL forum and no contribute at all...
Best regards
Lucas
Hi,
It depends on how you implemented the list. Please send a short code snippet to see it.
Hi @kisvegabor,
I only achieve like this so far. How can I show the two txt in a label? Should I use a great many blanks to connect Channel-1
with ON/OFF
? And my code:
const char * txts[1][13] =
{
{TYM_SYMBOL_ACTIVITY_ON, "Channel-1", TYM_SYMBOL_ACTIVITY_ON, "Channel-2",
TYM_SYMBOL_ACTIVITY_ON, "Channel-3",TYM_SYMBOL_ACTIVITY_ON, "Channel-4",NULL},
}
struct pageInfo
{
lv_obj_t * cont;
lv_group_t * group;
const char ** txt;
lv_obj_t * list;
bool hide;
};
void MasterMenu_create(PageInfo * info)
{
lv_obj_t * parent = info->cont;
lv_obj_set_auto_realign(parent, true);
lv_obj_align_origo(parent, NULL, LV_ALIGN_CENTER, 0, 0);
lv_cont_set_fit(parent, LV_FIT_TIGHT);
lv_cont_set_layout(parent, LV_LAYOUT_COLUMN_MID);
btn = lv_btn_create(parent,NULL);
lv_obj_set_size(btn,320,40);
lv_obj_set_pos(btn, 0, 0);
title_label1 = lv_label_create(btn,NULL);
lv_label_set_text(title_label1, TYM_SYMBOL_BACK_LEFT" Master Menu");
lv_label_set_align(title_label1,LV_LABEL_ALIGN_LEFT);
lv_btn_set_layout(btn,LV_LAYOUT_ROW_MID);
info->list = lv_list_create(parent, NULL);
lv_obj_set_size(info->list, 320, 200);
lv_obj_set_pos(info->list,0,40);
uint32_t i;
for(i = 0; info->txt[i] != NULL; i+=2)
{
list_btn = lv_list_add_btn(info->list, info->txt[i], info->txt[i+1]);
lv_obj_move_foreground(lv_list_get_btn_label(list_btn));
lv_btn_set_checkable(list_btn, true);
lv_group_add_obj(info->group, list_btn);
}
}
Thanks a lot!
Thanks!
I’ve added a minor fix to the master branch of LVGL to make possible adding extra label to list button like this:
lv_obj_t * label = lv_label_create(list_btn, NULL);
lv_obj_add_protect(label, LV_PROTECT_POS);
lv_label_set_text(label, "On");
lv_obj_align(label, NULL, LV_ALIGN_IN_RIGHT_MID, -15, 0);
...
/*Get the label later from the list button (e.g. in an event)*/
label = lv_obj_get_child(list_btn, NULL);
lv_label_set_text(label, "Off");
lv_obj_align(label, NULL, LV_ALIGN_IN_RIGHT_MID, -15, 0);
Hi @kisvegabor,
Thanks! It is working!
Actually, I have an idea. Could we have the API--`lv_lable_set_cell_value` just like `lv_table_set_cell_value`?
Best reagard,
lucas
Can you describe what could this function exacly do?
For using label in some complex case…
Hi gabor,
I need to achieve this,
But here’s what’s been achieved so far.
Meanwhile, It doesn’t work I use lv_obj_set_size
either. The label’s coords always is small, which is seemed like that changed by signal in call stack.
You’ll probably need to change the label’s text wrapping policy to change its size.