Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 23:43, 2 January 2008.

Pop up list example

From Forum Nokia Wiki


The SelectSomethingL() method illustrates how to use Popup lists for displaying data or for showing a selection to the user. In this example five constant strings are added to the selection but you could also make this part dynamic.

With this example the Popup list is constructed as CAknSinglePopupMenuStyleListBox, but you could also use following types of Popuplists:

  • CAknSingleHeadingPopupMenuStyleListBox
  • CAknSingle2GraphicPopupMenuStyleListBox
  • CAknSingleGraphicPopupMenuStyleListBox
  • CAknSingleGraphicHeadingPopupMenuStyleListBox
  • CAknSingleGraphicBtPopupMenuStyleListBox
  • CAknDoubleGraphicPopupMenuStyleListBox
  • CAknDouble2PopupMenuStyleListBox
  • CAknDoublePopupMenuStyleListBox
  • CAknDoubleLargeGraphicPopupMenuStyleListBox

Note that the format for the item text string depends on the Popup list type. If you change the Popup list type you also need to modify the item text string format accordingly.


_LIT(KtxPopUpTitle			,"Select item");
 
_LIT(KtxPopUpItem1			,"Item 1");
_LIT(KtxPopUpItem2			,"Item 2");
_LIT(KtxPopUpItem3			,"Item 3");
_LIT(KtxPopUpItem4			,"Item 4");
_LIT(KtxPopUpItem5			,"Item 5");
 
void SelectSomethingL(TDes& aSelected)
{
    CAknSinglePopupMenuStyleListBox* list =
new(ELeave)CAknSinglePopupMenuStyleListBox;
    CleanupStack::PushL(list);
 
    CAknPopupList* popupList = CAknPopupList::NewL(list,
R_AVKON_SOFTKEYS_OK_BACK, AknPopupLayouts::EMenuWindow);  
    CleanupStack::PushL(popupList);
 
    list->ConstructL(popupList, 0);
    list->CreateScrollBarFrameL(ETrue);
    list->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
CEikScrollBarFrame::EAuto);
 
    CDesCArrayFlat* ItemArray = new(ELeave)CDesCArrayFlat(5);
    CleanupStack::PushL(ItemArray);
 
    // add the item adding in here..
    ItemArray->AppendL(KtxPopUpItem1); 
    ItemArray->AppendL(KtxPopUpItem2); 
    ItemArray->AppendL(KtxPopUpItem3); 
    ItemArray->AppendL(KtxPopUpItem4); 
    ItemArray->AppendL(KtxPopUpItem5); 
 
    CleanupStack::Pop();            //ItemArray
    list->Model()->SetItemTextArray(ItemArray);
    list->Model()->SetOwnershipType(ELbmOwnsItemArray);
 
    popupList->SetTitleL(KtxPopUpTitle);
 
    // Show popup list and then show return value.
    TInt popupOk = popupList->ExecuteLD();
    if (popupOk)
    {
    	TInt Sel = list->CurrentItemIndex();
    	if (Sel >= 0 && Sel < ItemArray->MdcaCount())
    	{
    	    aSelected.Copy(ItemArray->MdcaPoint(Sel));
    	}
    }
	
    CleanupStack::Pop();            // popuplist
    CleanupStack::PopAndDestroy(1); // list
}
Related Discussions
Thread Thread Starter Forum Replies Last Post
HTTP Example Access Point say2paul Symbian Networking & Messaging 1 2006-07-14 17:26
Predictive Text. Candidate List window possible? bharath_hegde General Symbian C++ 1 2006-11-05 16:47
wehre to delete statuspane when app exit.... roman.ahmed General Symbian C++ 9 2007-10-31 11:48
Nokia Audio Suite 1 Question manteca Audio 3 2003-08-11 15:46
CAknCheckBoxSettingPage bcchong General Symbian C++ 3 2007-07-20 11:02
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX