【问题标题】:Unable to navigate between the two screens while using grid layout in tizen native在 tizen native 中使用网格布局时无法在两个屏幕之间导航
【发布时间】:2021-02-08 14:20:24
【问题描述】:

在 Tizen 本机中使用网格布局时无法在两个屏幕之间导航。我单击 SCREEN1 上的 button1,它将打开具有 YES 和 NO 按钮的 SCREEN2。当我单击“否”按钮时,它应该返回到 SCREEN1 - 但现在发生的情况是当我单击“否”按钮时会显示黑屏。如果我单击“是”按钮,它会打开一个弹出屏幕,其中显示一条消息 5 秒钟,然后它应该返回到 SCREEN1,但现在它又返回到 SCREEN2。以下代码是使用的任何人都可以检查和帮助。谢谢

    static void
    screen1_button_clicked(void *data, Evas_Object *obj, void *event_info){

    Evas_Object *nf = data;
    Evas_Object *grid;

    /* Grid Layout */
    grid = elm_grid_add(nf);
    evas_object_show(grid);
    elm_object_content_set(nf, grid);
    elm_naviframe_item_push(nf, "Screen 2", NULL, NULL, grid, NULL);

    /* Decline Button */
    no_button = elm_button_add(grid);
    elm_object_style_set(no_button, "circle");
    elm_grid_pack(grid, no_button, 5, 35, 50, 50);
    evas_object_show(no_button);
    evas_object_smart_callback_add(no_button, "clicked",no_button_clicked, nf);

    /* Decline Button - Icon */
    no_button_icon = elm_icon_add(no_button);
    elm_image_file_set(no_button_icon,ICON_DIR"/no_button.png",NULL);
    evas_object_size_hint_min_set(no_button_icon, 100, 100);
    evas_object_size_hint_max_set(no_button_icon, 100, 100);
    elm_object_part_content_set(no_button,"icon",no_button_icon);
    evas_object_show(no_button_icon);

    /* Confirm Button */
    yes_button = elm_button_add(grid);
    elm_object_style_set(yes_button, "circle");
    elm_grid_pack(grid, yes_button, 45, 35, 50, 50);
    evas_object_show(yes_button);
    evas_object_smart_callback_add(yes_button, "clicked", yes_button_clicked, nf);
    /* Confirm Button - Icon */
    yes_button_icon = elm_icon_add(yes_button);
    elm_image_file_set(yes_button_icon,ICON_DIR"/yes_button.png",NULL);
    evas_object_size_hint_min_set(yes_button_icon, 100, 100);
    evas_object_size_hint_max_set(yes_button_icon, 100, 100);
    elm_object_part_content_set(yes_button,"icon",yes_button_icon);
    evas_object_show(yes_button_icon);
}

    static void
    no_button_clicked(void *data, Evas_Object *obj, void *event_info){

    Evas_Object *nf = data;
    elm_naviframe_item_pop(nf);

}
    /* Base Gui */

    /* Naviframe */
    ad->navi = elm_naviframe_add(ad->conform);
    evas_object_show(ad->navi);
    elm_object_content_set(ad->conform, ad->navi);

    /* Grid Layout */
    ad->grid = elm_grid_add(ad->navi);
    elm_object_content_set(ad->navi, ad->grid);
    evas_object_show(ad->grid);

    ad->navi_item = elm_naviframe_item_push(ad->navi, "Screen 1", NULL,NULL, ad->grid, NULL);

    /* Button */
    screen1_button = elm_button_add(ad->grid);
    elm_object_style_set(screen1_button, "circle");
    elm_grid_pack(ad->grid, screen1_button, 15, 37, 35, 50);
    evas_object_show(screen1_button);

    screen1_button_icon = elm_icon_add(screen1_button);
    elm_image_file_set(screen1_button_icon,ICON_DIR"/button1.png",NULL);
    evas_object_size_hint_min_set(screen1_button_icon, 123, 123);
    evas_object_size_hint_max_set(screen1_button_icon, 123, 123);
    elm_object_part_content_set(screen1_button,"icon",screen1_button_icon);
    evas_object_show(screen1_button_icon);
    evas_object_smart_callback_add(screen1_button, "clicked",screen1_button_clicked, ad->navi);

【问题讨论】:

    标签: c tizen tizen-wearable-sdk tizen-native-app


    【解决方案1】:

    这似乎是小部件之间不必要的父子组合引起的问题。

    elm_object_content_set(ad->navi, ad->grid);

    naviframe 小部件本身没有用于放置网格的容器区域, 但是由于上述 API 调用,网格被添加到了 naviframe 的子对象中。

    之后,使用不同的网格对象调用相同的 API。

    elm_object_content_set(nf, grid);

    发生这种情况时,naviframe 会减去旧的子对象并构造一个新对象作为子对象。 被拖放的子对象成为一个孤立的对象,不会出现在屏幕上。

    不需要为 naviframe 调用 content_set。 naviframe的item变成一个view,每个view都有一个容器区域。

    https://docs.tizen.org/application/native/guides/ui/efl/container-naviframe/

    请参阅上面的指南,您可以了解 naviframe 如何处理项目。

    无论如何,您的问题的解决方案是删除 "elm_object_content_set(nf, grid);"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-21
      • 1970-01-01
      • 1970-01-01
      • 2018-07-14
      • 1970-01-01
      • 2021-10-14
      • 2014-05-03
      • 1970-01-01
      相关资源
      最近更新 更多