简体   繁体   中英

Native Tizen - How to remove image?

Adding new window and popping it works based on Tizen developer docs tutorial . But when I add a image on the second window, after popping it, the image does not vanish.

Here's the code on second window with image added:

static void list_item_doubleclicked_cb(void *data, Evas_Object *obj, void *event_info){
Evas_Object *navi_button;
Evas_Object *nf = data;
Elm_Object_Item *nf_it;


Evas_Object *image = elm_image_add(nf);
evas_object_move(image, 0, 0);
evas_object_resize(image, 400, 300);
evas_object_show(image);

char img_path[128];
char *res_path = app_get_resource_path();
snprintf(img_path, sizeof(img_path), "%s%s%s", res_path, "images/","myImage.png");

elm_image_file_set(image, img_path, NULL);


navi_button = elm_button_add(nf);
elm_object_text_set(navi_button, "Prev");
elm_object_style_set(navi_button, "bottom");
evas_object_smart_callback_add(navi_button, "clicked",
                               prev_btn_clicked_cb, nf);

nf_it = elm_naviframe_item_push(nf, "Second view", NULL,
                                NULL, navi_button, NULL);
}

Here the pop function can clear the button and second window title but it doesn't clear the image.

All the other code is similar to the linked tutorial. The image stays on screen. I need to remove it, How can I?

Rifat.

Basically Evas Object dosen't belong to any smart object parents. Its lifetime and basic behaviors works independently, not managed. Thus you need to control it manually. However, if you add an image object to a specific smart object parent, the image instance can be managed by its parent. Meaning, If the parent is deleted, its children are deleted as well. Mostly *Container widget works as the smart object parent.

You created an image object correctly.But you didn't put it into any containers. Naviframe is designed to have a view of the containers such as elm_layout, elm_box, grid, table, etc. You can compose a view using one of them while putting children into the container. Thus when naviframe popping is happened, the layout will be removed by naviframe and its children including your image will be removed as well since it's a child of the container.

Otherwise, you should delete image object by explicitly call evas_object_del(); when view is popping. Or hide it by call evas_object_hide() when a further view is pushed.

Hopefully my description is understandable by you. Thansk.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM