首 页 | 新 闻 | Symbian | Windows Mobile| J2ME | 下载中心 | 游戏策划 | 购书指南 | 移动开发视频教程
您现在的位置: 开发视界 >> 专家专栏 >> 孙东风 >> 文章正文
Symbian开发笔记(二)
作者:孙东风    文章来源:本站原创    更新时间:2008-4-2 9:56:29

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

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"));
 }

相关文章:
Symbian开发笔记(一)
 
公告
原创文章转载请注明出处
      -孙东风
昵称:Crazy Wind
QQ :545356884
MSN:sundongfeng1227@
    hotmail.com

   承接J2ME、Symbian开发项目,尤其在联网游戏、应用开发方面有独特的优势!