Symbian开发笔记(二)

创建一个弹出式的模态列表:

void CContAppUi::ShowMobilePopListL()
 {
 
 CEikTextListBox* list = new(ELeave) CAknSinglePopupMenuStyleListBox;
 CleanupStack::PushL(list);

 // Create popup list and PUSH it.
 CAknPopupList* popupList = CAknPopupList::NewL(
                                        list, R_AVKON_SOFTKEYS_MENU_LIST,
                                        AknPopupLayouts::EMenuWindow);
 CleanupStack::PushL(popupList);

 // initialize listbox.
 list->ConstructL(popupList, CEikListBox::ELeftDownInViewRect);
 list->CreateScrollBarFrameL(ETrue);
 list->ScrollBarFrame()->SetScrollBarVisibilityL(
                                CEikScrollBarFrame::EOff,
                                CEikScrollBarFrame::EAuto);
 MDesCArray* itemList = list->Model()->ItemTextArray();
 CDesCArray* items = (CDesCArray*) itemList;
 
 FillList(items);

 popupList->SetTitleL(_L("Title of the dialog"));

 // Show popup list and then show return value.
 TInt popupOk = popupList->ExecuteLD();
 //If the user enters ok on a selection
 if (popupOk)
 {
  //Do what you have to do
     TInt index = list->CurrentItemIndex();
     TBuf<KMessageLength> msg;
     /**
     TBuf<KMessageLength> format;
     iCoeEnv->ReadResource( format, R_AKNEXPOPLIST_SELECT_MESSAGE );
     */
     _LIT(format,"Item %d was selected.");
    
     msg.Format( format, index + 1 );
     CAknNoteDialog* dlg = new( ELeave ) CAknNoteDialog(
                                             CAknNoteDialog::ENoTone,
                                             CAknNoteDialog::ENoTimeout );
 
     dlg->PrepareLC(  R_AKNEXPOPLIST_SELECT_MESSAGE_NOTE  );
     dlg->SetTextPluralityL(  EFalse  );
     dlg->SetTextL(  msg  );
     dlg->RunLD();
 }
 CleanupStack::Pop();
 CleanupStack::PopAndDestroy();
  
}

void CContAppUi::FillList(CDesCArray* items)
 {
 items->AppendL(_L("test1"));
 items->AppendL(_L("test2"));
 items->AppendL(_L("test3"));
 items->AppendL(_L("test4"));
 items->AppendL(_L("test5"));
 }

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值