0

我正在为表盘开发一个 Tizen 原生应用程序。

我使用默认的 create_base_gui 函数创建了基本 gui:

typedef struct appdata {
    Evas_Object *win;
    Evas_Object *conform;
    Evas_Object *label;
    Evas_Object *box;
} appdata_s;

static void
create_base_gui(appdata_s *ad, int width, int height)
{
    int ret;
    watch_time_h watch_time = NULL;

    /* Window */
    ret = watch_app_get_elm_win(&ad->win);
    if (ret != APP_ERROR_NONE) {
        dlog_print(DLOG_ERROR, LOG_TAG, "failed to get window. err = %d", ret);
        return;
    }

    evas_object_resize(ad->win, width, height);

    /* Conformant */
    ad->conform = elm_conformant_add(ad->win);
    evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(ad->win, ad->conform);

    /* Box */
    ad->box = elm_box_add(ad->conform);
    evas_object_show(ad->box);
    elm_object_content_set(ad->conform, ad->box);

    ad->label = elm_label_add(ad->box);
    evas_object_size_hint_align_set(ad->label, 0.5, 0.5);
    elm_object_text_set(ad->label, "Time");
    evas_object_show(ad->label);
    elm_box_pack_end(ad->box, ad->label);

    ret = watch_time_get_current_time(&watch_time);
    if (ret != APP_ERROR_NONE)
        dlog_print(DLOG_ERROR, LOG_TAG, "failed to get current time. err = %d", ret);

    update_watch(ad, watch_time, 0);
    watch_time_delete(watch_time);

    /* Show window after base gui is set up */
    evas_object_show(ad->win);
}

在 update_watch 函数中,我尝试使用以下代码更新文本:

static void
update_watch(appdata_s *ad, watch_time_h watch_time, int ambient)
{
    char watch_text[TEXT_BUF_SIZE];
    int hour24, minute, second;
    int time;

    if (watch_time == NULL)
        return;

    watch_time_get_hour24(watch_time, &hour24);
    watch_time_get_minute(watch_time, &minute);
    watch_time_get_second(watch_time, &second);

    elm_object_text_set(ad->label, "Update" );
}

但它不起作用。

有什么错误?

4

1 回答 1

1

一开始。你错过了evas_object_show(ad->conform); 它使不可见的控件处于一致状态。(盒子和标签。)

如果您的更新监视功能每次都不起作用,请使其在结构中的time_tick回调中调用。watch_app_lifecycle_callback_s

于 2016-08-12T10:51:10.627 回答