Managing list content
This code snippet demonstrates multiple ways of managing contant of an elementary list widget.
const char * labels[] = { "Item 0", "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8",
"Item 9" };
static void list_test(Evas_Object *parent) {
Evas_Object *box = elm_box_add(parent);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(parent, box);
evas_object_show(box);
//create a list
Evas_Object *list = elm_list_add(parent);
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, list);
int labelsCnt = sizeof(labels) / sizeof(labels[0]);
Elm_Object_Item *items[labelsCnt];
for (int i = 0; i < labelsCnt; i++)
items[i] = elm_list_item_append(list, labels[i], NULL, NULL, NULL, NULL);
//delete an item
elm_object_item_del(items[0]);
//insert item after another item
elm_list_item_insert_after(list, items[5], "after", NULL, NULL, NULL, NULL);
//insert item before another item
elm_list_item_insert_before(list, items[5], "before", NULL, NULL, NULL, NULL);
//insert item at the beginning of the list
elm_list_item_prepend(list, "prepended", NULL, NULL, NULL, NULL);
//insert item at the end of the list
elm_list_item_append(list, "appended", NULL, NULL, NULL, NULL);
//clear the list
//elm_list_clear(list);
evas_object_show(list);
elm_list_go(list);
}