\chapter{List widget example}
\hypertarget{list_example_02}{}\label{list_example_02}\index{List widget example@{List widget example}}
This code places a single Elementary list widgets on a window, exemplifying a part of the widget\textquotesingle{}s API.

First, we will just create a simple list, as done on \doxysectlink{list_example_01}{List widget example}{0} \+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *lbl[]\ =}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Sunday"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Monday"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Tuesday"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Wednesday"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Thursday"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Friday"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Saturday"{}}}
\DoxyCodeLine{\ \ \ \ \ \};}
\DoxyCodeLine{\ \ \ li\ =\ \mbox{\hyperlink{group__Elm__List__Group_gaf6389bff5604ff879bc572ab12494dd2}{elm\_list\_add}}(win);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9379629ad8ad2860aa786d838a4a106a}{evas\_object\_size\_hint\_weight\_set}}(li,\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}},\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Win__Group_ga505d6bd217e5ee01e82b548ec35986eb}{elm\_win\_resize\_object\_add}}(win,\ li);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ \textcolor{keyword}{sizeof}(lbl)\ /\ \textcolor{keyword}{sizeof}(lbl[0]);\ i++)}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga5f2fecdca079df9522ac4f8e64b2d98e}{elm\_list\_item\_append}}(li,\ lbl[i],\ NULL,\ NULL,\ NULL,\ NULL);}

\end{DoxyCodeInclude}
 Now, let\textquotesingle{}s customize this list a bit. First we will display items horizontally\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga167b13474094e21963e60ea01664f7e7}{elm\_list\_horizontal\_set}}(li,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}

\end{DoxyCodeInclude}
 Then we will choose another list mode. There are four of them, and the default \doxylink{group__Elm__General_gad05499f0b0c907a953ef8650823ae428}{Elm\+\_\+\+List\+\_\+\+Mode} is \doxylink{group__Elm__General_ggad05499f0b0c907a953ef8650823ae428a66e50ab227b49eaecd5512fbf6cd4b5f}{ELM\+\_\+\+LIST\+\_\+\+SCROLL}. Let\textquotesingle{}s set compress mode\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga8de4384bc5c40089644ecab6a7e005c8}{elm\_list\_mode\_set}}(li,\ \mbox{\hyperlink{group__Elm__General_ggad05499f0b0c907a953ef8650823ae428ae56e6756bfcf33e3a53fb14acf8d3497}{ELM\_LIST\_COMPRESS}});}

\end{DoxyCodeInclude}
 To enable multiple items selection, we need to enable it, since only one selected item is allowed by default\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_gabc84c1234bd9cf0b306e31f5d10829e6}{elm\_list\_multi\_select\_set}}(li,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}

\end{DoxyCodeInclude}
 We are not adding items with callback functions here, since we\textquotesingle{}ll explain it better on \doxysectlink{list_example_03}{List -\/ Items management}{0}. But if the callback need to be called everytime user clicks an item, even if already selected, it\textquotesingle{}s required to enable this behavior\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_gaa5dff03378e2c410f8a04953aefa6961}{elm\_list\_select\_mode\_set}}(li,\ \mbox{\hyperlink{group__Elm__General_gga8e4aa5aa238e472f33813babfff0d56fab3cfbf566fdbea2079f3081969f0c59c}{ELM\_OBJECT\_SELECT\_MODE\_ALWAYS}});}

\end{DoxyCodeInclude}
 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. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Scroller__Group_gae69101dbdb089598ca790c73bd9d7a42}{elm\_scroller\_bounce\_set}}(li,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}},\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Scroller__Group_ga4105c0d6adca64ed3d38e7e4116b09e4}{elm\_scroller\_policy\_set}}(li,\ \mbox{\hyperlink{group__Elm__Scroller__Group_ggae4532876fde43d8d37fc9440a1e36a84a9a3e639489c64f070d4caa6cafc22870}{ELM\_SCROLLER\_POLICY\_AUTO}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Scroller__Group_ggae4532876fde43d8d37fc9440a1e36a84a74e67e8e341f5069ec27244c2a41053f}{ELM\_SCROLLER\_POLICY\_ON}});}

\end{DoxyCodeInclude}
 See the full \doxylink{list_example_02_8c-example}{list\+\_\+example\+\_\+02.c} code, whose window should look like this picture\+:

 
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{screenshots/list_example_02}}
\end{DoxyImageNoCaption}
 