微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 tizen native 中使用网格布局时无法在两个屏幕之间导航

如何解决在 tizen native 中使用网格布局时无法在两个屏幕之间导航

在 Tizen 本机中使用网格布局时无法在两个屏幕之间导航。我点击了 SCREEN1 上的 button1,这将打开 SCREEN2,其中有 YES 和 NO 按钮。当我单击“否”按钮时,它应该返回到 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,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);
    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,yes_button,45,50);
    evas_object_show(yes_button);
    evas_object_smart_callback_add(yes_button,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);
    evas_object_size_hint_max_set(yes_button_icon,100);
    elm_object_part_content_set(yes_button,yes_button_icon);
    evas_object_show(yes_button_icon);
}

    static void
    no_button_clicked(void *data,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",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,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);
    elm_object_part_content_set(screen1_button,screen1_button_icon);
    evas_object_show(screen1_button_icon);
    evas_object_smart_callback_add(screen1_button,screen1_button_clicked,ad->navi);

解决方法

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

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

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

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

elm_object_content_set(nf,grid);

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

不需要为 naviframe 调用 content_set。 naviframe的item变成一个view,每个view都有一个container area。

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

查看以上指南,您可以了解 naviframe 如何处理项目。

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?