Unable to navigate between the two screens while using grid layout in Tizen native. I click on a button1 on SCREEN1 which will open SCREEN2 which has YES and NO buttons. When I click on No button it should go back to the SCREEN1 - but what happens now is when I click on NO button a black screen is displayed. If I click on YES button it opens a popup screen with a message which is displayed for 5 seconds and then it should go back to the SCREEN1 but now it goes back to SCREEN2. The following code is what is used could anyone please check and help. thanks
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);
It seems to be an issue caused by unnecessary parent and child composition between widgets.
elm_object_content_set(ad->navi, ad->grid);
The naviframe widget itself does not have a container area to put the grid in, but the grid was added to the sub object of the naviframe due to the above API call.
after that the same API was called with a different grid object.
elm_object_content_set(nf, grid);
When this happens, the naviframe subtracts the old sub object and constructs a new object as a child. The sub-object that has been dropped becomes an isolated object and does not appear on the screen.
there is no need to call content_set for naviframe. The item of naviframe becomes one view, and each view has a container area.
https://docs.tizen.org/application/native/guides/ui/efl/container-naviframe/
See above guide you can understand how naviframe works with items.
Anyway solution for your problem is delete "elm_object_content_set(nf, grid);"