Week 23 contribution of PDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE concept
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-210606BE-A36C-4B65-B083-93F71024196C" xml:lang="en"><title>Setting
the item selected when the choice list is opened</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>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 <codeph>EAknChoiceListWithCurrentSelection</codeph>. </p>
<p>If you do not set the selected item, the first item in the list is initially
selected by default.</p>
<p>For details on how the choice list items are indexed, see <xref href="GUID-845F3021-E3ED-4676-916A-75740886DCBD.dita">Using
the Choice list API</xref>.</p>
<codeblock xml:space="preserve">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() );
}
</codeblock>
</conbody></concept>