我的EDC布局文件中有一个文本字段,我希望在按钮点击时获取该数据。我对此一无所知。那么,有人会帮助我吗?
答案 0 :(得分:0)
代码来自布局和按钮examples。以下是其他语言绑定的示例(c,c ++,js)。
按钮和布局(原生)的相应Tizen documentation。
.edc
布局文件,其中包含文本部分"title"
和占位符/ SWALLOW部分"placerholder"
以放置按钮。
collections {
group {
name: "example/mylayout";
data {
item: "title" "Layout Example 01";
}
parts {
part {
name: "example/title";
type: TEXT;
description {
state: "default" 0.0;
color: 0 0 0 255;
rel1 {
relative: 0.0 0.0;
offset: 0 0;
}
rel2 {
relative: 1.0 0.5;
offset: -1 -1;
}
text {
text: "bla";
size: 16;
font: "sans";
min: 1 1;
ellipsis: -1;
}
}
}
part {
name: "placleholder";
type: SWALLOW;
description {
state: "default" 0.0;
fixed: 1 1;
rel1 {
relative: 0.0 0.5;
offset: 0 0;
}
rel2 {
relative: 1.0 1.0;
offset: -1 -1;
}
}
}
}
}
要设置布局,请添加一个按钮,然后阅读旧版C中"title"
部分的文本,如下所示(不是完整的工作示例,因为我无法测试):
设置布局:
Evas_Object *win, *bt, *layout;
// Create a window ( I don't know if this works in tizen like this.)
win = elm_win_util_standard_add("layout", "Layout");
elm_win_autodel_set(win, EINA_TRUE);
// Adding layout and make it fill the window
layout = elm_layout_add(win);
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, layout);
elm_layout_file_set(layout, "/path/to/layoutfile.edj", "example/mylayout");
evas_object_show(layout);
添加按钮:
bt = elm_button_add(layout);
elm_object_text_set(bt, "Get the text");
// put the button into the layout
elm_object_part_content_set(layout, "placeholder", bt);
// add clicked callback to button, pass the layout reference as data pointer
evas_object_smart_callback_add(bt, "clicked", _btn_cb, layout);
按钮回调:
static void
_btn_cb(void *data, Evas_Object *btn EINA_UNUSED, void *event_info EINA_UNUSED)
{
// data pointer is the layout reference
Evas_Object *layout = data;
// with the layout reference we can get the text of part "title"
const char *text = elm_object_part_text_get(layout, "title");
}
代码来自布局和按钮examples。以下是其他语言绑定的示例(c,c ++,js)。