diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-462239D1-4B40-4342-92DA-32AB0AF0D2F2.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-462239D1-4B40-4342-92DA-32AB0AF0D2F2.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,73 @@ + + + + + +Creating +the choice list +

To use a choice list in your application, create an instance of the class CAknChoiceList.

+

Use the CAknChoiceList::NewL parameters to set the style +of the choice list.

+

If you give no parameters, the defaults will be used. With the default +parameters, a choice list with current selection is constructed.

+

To construct a choice list without a current selection, use the flag CAknChoiceList::EaknChoiceListWithoutCurrentSelection and +an instance of CaknButton in the constructor. This button +will be then used to open the choice list. The ownership of the button is +transferred to the choice list.

+

The following sample code illustrates creating a default choice list.

+const TInt KArrayGranularity ( 1 ); + + // Create array of choice list items + CDesCArrayFlat* array = new ( ELeave ) CDesCArrayFlat ( KArrayGranularity ); + CleanupStack::PushL( array ); + + _LIT( KListItem, "Item %d" ); + + for ( TInt k = 0; k < 5; k++ ) + { + TBuf<32> buf; + buf.Format( KListItem, k ); + array->AppendL( buf ); + } + + // Create choice list with array + iChoiceList = CAknChoiceList::NewL( this, array ); + + CleanupStack::Pop( array ); + + iChoiceList->SetObserver( this ); + +

The following sample code illustrates creating a button choice list with +items from resources:

+ _LIT( KButtonTxt, "Choice list" ); + _LIT( KButtonHelpTxt, "Button help text" ); + + // Create a button for the choice list + CAknButton* button = CAknButton::NewLC( NULL, + NULL, + NULL, + NULL, + KButtonTxt, + KButtonHelpTxt, + KAknButtonSizeFitText, + 0 ); + + // Create empty Choice list + iChoiceList = CAknChoiceList::NewL( this, NULL, + CAknChoiceList::EAknChoiceListWithoutCurrentSelection, button ); + CleanupStack::Pop( button ); + + // Add items from resource + iChoiceList->SetItemsL( R_CHOICELISTEX_ITEM_ARRAY ); + iArraySize = ArraySizeL( R_CHOICELISTEX_ITEM_ARRAY ); + iSelection = 0; + + iChoiceList->SetObserver( this ); + +
\ No newline at end of file