List widget example

This code places a single Elementary list widgets on a window, exemplifying a part of the widget's API.

First, we will just create a simple list, as done on List widget example :

static const char *lbl[] =
{
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};
li = elm_list_add(win);
evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
for (i = 0; i < sizeof(lbl) / sizeof(lbl[0]); i++)
elm_list_item_append(li, lbl[i], NULL, NULL, NULL, NULL);

Now, let's customize this list a bit. First we will display items horizontally:

elm_list_horizontal_set(li, EINA_TRUE);

Then we will choose another list mode. There are four of them, and the default Elm_List_Mode is ELM_LIST_SCROLL. Let's set compress mode:

elm_list_mode_set(li, ELM_LIST_COMPRESS);

To enable multiple items selection, we need to enable it, since only one selected item is allowed by default:

elm_list_multi_select_set(li, EINA_TRUE);

We are not adding items with callback functions here, since we'll explain it better on List - Items management. But if the callback need to be called everytime user clicks an item, even if already selected, it's required to enable this behavior:

elm_list_select_mode_set(li, ELM_OBJECT_SELECT_MODE_ALWAYS);

Finally, if a bounce effect is required, or you would like to see scrollbars, it is possible. But, for default theme, list scrollbars will be invisible anyway.

elm_scroller_bounce_set(li, EINA_TRUE, EINA_TRUE);
elm_scroller_policy_set(li, ELM_SCROLLER_POLICY_AUTO,

See the full list_example_02.c code, whose window should look like this picture:

list_example_02.png