Setting the item selected when the choice list is opened

You can set the list item that is initially selected when the choice list is shown to the user. This feature can be used with a choice list of the type EAknChoiceListWithCurrentSelection.

If you do not set the selected item, the first item in the list is initially selected by default.

For details on how the choice list items are indexed, see Using the Choice list API.

void CMyAppContainer::CreateChoiceListL()
    // Create empty Choice list
    iChoiceList = CAknChoiceList::NewL( this, NULL );
    // Add items from resource
    iChoiceList->SetItemsL( R_CHOICELISTEX_ITEM_ARRAY );
    // Set the default selected item
    iChoiceList->SetSelectedIndex( KDefaultIndex );
    iChoiceList->SetObserver( this );
    iChoiceList->SetRect( ChoiceListRect() );