|
|
User login
Feeds |
listbox not shown
|
|||||
| Sat, 2005-08-13 14:47 | |
|
i have tried all sorts of things but my listbox is not shown
code in .rss file RESOURCE LISTBOX r_simplelist_saved_listbox {  array_id = r_simplelist_saved_items;  flags = EAknListBoxSelectionList; } RESOURCE ARRAY r_simplelist_saved_items  {  items =   {     LBUF { txt = "Item1"; },     LBUF { txt = "Item2"; },     LBUF { txt = "Item3"; }   };  } code in multiviewcontainer2.cpp /* Copyright (c) 2003, Nokia. All rights reserved */ #include "MultiViewsContainer2.h" #include<barsread.h> #include <multiviews.rsg> #include <eikenv.h> #include <aknlists.h> //#include <techview.h> #include <eikclbd.h > #include <eikclb.h> #include<gulbordr.h> #include<eiktxlbx.h> CMultiViewsContainer2* CMultiViewsContainer2::NewL(const TRect& aRect)   {   CMultiViewsContainer2* self = CMultiViewsContainer2::NewLC(aRect);   CleanupStack::Pop(self);   return self;   } CMultiViewsContainer2* CMultiViewsContainer2::NewLC(const TRect& aRect)   {   CMultiViewsContainer2* self = new (ELeave) CMultiViewsContainer2;   CleanupStack::PushL(self);   self->ConstructL(aRect);     return self;   } void CMultiViewsContainer2::ConstructL(const TRect& aRect)   {    /*etRect(aRect);    CreateListL();    iMyListBox->SetRect(aRect);    iEikonEnv->AlertWin(_L("in 4"));   */     CreateWindowL(); CreateListL(); SetRect(aRect);  ActivateL();    } void CMultiViewsContainer2::CreateListL() { if ( iMyListBox ){ delete iMyListBox; iMyListBox = NULL; } iMyListBox = new (ELeave) CAknSingleStyleListBox; //CEikTextListBox iMyListBox-> SetContainerWindowL(*this); iMyListBox->ConstructL(this); iEikonEnv->AlertWin(_L("in 1")); TInt resourceId = R_SIMPLELIST_SAVED_LISTBOX; TResourceReader reader; iEikonEnv->CreateResourceReaderLC(reader,R_SIMPLELIST_SAVED_LISTBOX); iEikonEnv->AlertWin(_L("in 2")); iMyListBox->ConstructFromResourceL(reader); //CDesCArrayFlat* listBoxItems = iEikonEnv->ReadDesCArrayResourceL(resourceId);  //CTextListBoxModel* model = iMyListBox->Model(); //model->SetItemTextArray(listBoxItems); //model->SetOwnershipType(ELbmOwnsItemArray); //SizeChanged(); CleanupStack::PopAndDestroy(); //TPoint aPoint(10,30); //TSize aSize(128,128); //TRect r; //iMyListBox->SetExtent(aPoint, TSize(r.Width(), r.Height())); //iMyListBox->HandleItemAdditionL(); SizeChanged(); iMyListBox->ActivateL(); iAvkonAppUi->AddToStackL( iMyListBox ); //MakeVisible(ETrue); //iMyListBox->View()->ItemDrawer()->SetHighlightedBackColor(TRgb(0xb97a60)); //iMyListBox->DrawNow(); DrawNow(); } TInt CMultiViewsContainer2::CountComponentControls() const   {     if ( iMyListBox ) return 1; else return 0;   } void CMultiViewsContainer2::Draw(const TRect& aRect) const   {     CWindowGc& gc = SystemGc();   gc.Clear(); //  SetRect(*aRect); //  gc.SetPenStyle(CGraphicsContext::ENullPen); //  gc.SetBrushColor(KRgbWhite); //  gc.SetBrushStyle(CGraphicsContext::ESolidBrush); //  gc.DrawRect(aRect);   } CCoeControl* CMultiViewsContainer2::ComponentControl(TInt aIndex) const   {    switch(aIndex)    {    case 0: return iMyListBox;    break;       default: return NULL;    break;    }   } void CMultiViewsContainer2::SizeChanged()   { if ( iMyListBox ) iMyListBox->SetExtent(TPoint(0,0),TSize(176,160));   } code in multiviewsview2.cpp /* Copyright (c) 2003, Nokia. All rights reserved */ #include <aknviewappui.h> #include <aknconsts.h> #include <aknnotewrappers.h> #include <MultiViews.rsg> #include "MultiViewsView2.h" #include "MultiViewsContainer2.h" #include "MultiViews.hrh" CMultiViewsView2* CMultiViewsView2::NewL()   {   CMultiViewsView2* self = CMultiViewsView2::NewLC();   CleanupStack::Pop(self);   return self;   } CMultiViewsView2* CMultiViewsView2::NewLC()   {   CMultiViewsView2* self = new (ELeave) CMultiViewsView2();   CleanupStack::PushL(self);   self->ConstructL();   return self;   } CMultiViewsView2::CMultiViewsView2()   {     // No implementation required   } CMultiViewsView2::~CMultiViewsView2()   {   // No implementation required   } void CMultiViewsView2::ConstructL()   {   BaseConstructL(R_MULTIVIEWS_VIEW2);   } TUid CMultiViewsView2::Id() const   {   return TUid::Uid(EMultiViewsView2Id);   } void CMultiViewsView2::DoActivateL(const TVwsViewId& /*aPrevViewId*/,                   TUid /*aCustomMessageId*/,                   const TDesC8& /*aCustomMessage*/)   {   ASSERT(!(iContainer));   iContainer = CMultiViewsContainer2::NewL(ClientRect());   } void CMultiViewsView2::DoDeactivate()   {   if (iContainer)     {     AppUi()->RemoveFromStack(iContainer);     delete iContainer;     iContainer = NULL;     }     iEikonEnv->AlertWin(_L("in 5"));   } void CMultiViewsView2::HandleCommandL(TInt aCommand)   {     if (aCommand == EMultiViewsCommand1)     {     _LIT(message,"Hello");     CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;     informationNote->ExecuteLD(message);     }   else if (aCommand == EMultiViewsSwitchToView1)     {     AppUi()->ActivateLocalViewL(TUid::Uid(EMultiViewsView1Id));     }   else     {     AppUi()->HandleCommandL(aCommand);     }   } |
|
Forum posts: 176
You gave to less informations! Are you using debugger or phone? Mostly youre container will crash down to the view (Thats what the cleanupstack is for) and yore are holding a clean environment...
Try debugging from "ConstructL(const TRect& aRect)" till "CreateListL()". Several times i've had problems with the resources
It's fine to post code, but
regards;
CG
Forum posts: 1
iMyListBox->ConstructL(this);
or
iMyListBox->ConstructFromResourceL(reader);
not both
Forum posts: 1
I had a similar problem.
Just in case I might save 30' to future visitants in this forum, I was missing the iListBox->setSize(aRect) call in the container ConstructL method.
regards