×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    165

    How to open a Container from a ListBox Item?

    Hai, I created the listBox and added 3 Items(Encrypt,Decrypt,Options) in ListBox.When ListBox item "Options" is clicked second container must be opened?How to do this?Please help me......

    ////////////////////////////In Container.cpp////////////////////////////////////////
    iListBox = new (ELeave) CAknSingleStyleListBox();

    // Construct listbox
    iListBox->ConstructL( this, EAknListBoxSelectionList | EAknListBoxMultiselectionList |EAknListBoxMarkableList);
    iListBox->SetContainerWindowL( *this );

    // Set scrollbars
    iListBox->CreateScrollBarFrameL( ETrue );
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );

    // Create listbox item array
    iListBoxItems = new (ELeave) CDesCArrayFlat(4);

    // Create listbox items
    iListBoxItems->AppendL( _L("\tEncrypt\t") );
    iListBoxItems->AppendL( _L("\tDecrypt\t") );
    iListBoxItems->AppendL( _L("\tOptions\t") );

    // Add items to listbox
    iListBox->Model()->SetItemTextArray( iListBoxItems );

    // Listbox deletes the item array
    iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
    iListBox->HandleItemAdditionL( );
    ///////////////////////////////////////////////////////////////////////////////////////

    Thanks,
    Jennie.

  2. #2
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: How to open a Container from a ListBox Item?

    When you click on a list box item the "HandleListBoxEventL()" would be called by the framework. Check for the listbox item, whether it was options, if yes, activate your second view.

    Priju

  3. #3
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    165

    Re: How to open a Container from a ListBox Item?

    Hai Priju,
    I added the following code
    void CSecureDBContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
    {
    if (aEventType == EEventItemClicked)
    {
    Appui()->ActivateLocalViewL( ESecureDBContainer2ViewId );
    }
    }
    But when I debug the code in ListBox Item click,not entering into this event?Why?

  4. #4
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: How to open a Container from a ListBox Item?

    Quote Originally Posted by jennie View Post
    Hai Priju,
    I added the following code
    void CSecureDBContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
    {
    if (aEventType == EEventItemClicked)
    {
    Appui()->ActivateLocalViewL( ESecureDBContainer2ViewId );
    }
    }
    But when I debug the code in ListBox Item click,not entering into this event?Why?
    You could handle it with "EEventEnterKeyPressed". When you press the center/enter key the corresponding event would be called. Replace EEventItemClicked by EEventEnterKeyPressed.

    Priju

  5. #5
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    165

    Re: How to open a Container from a ListBox Item?

    Hai Priju,
    Thanks for ur reply.I replace EEventItemClicked with EEventEnterKeyPressed.But whenever "Options"(ListBox Item) is selected and press enter the application is closing and is giving Eik CTL 25 Error Code.Why Iam getting this error?Pls help me...

    Thanks,
    Jennie.

  6. #6
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: How to open a Container from a ListBox Item?

    Quote Originally Posted by jennie View Post
    Hai Priju,
    Thanks for ur reply.I replace EEventItemClicked with EEventEnterKeyPressed.But whenever "Options"(ListBox Item) is selected and press enter the application is closing and is giving Eik CTL 25 Error Code.Why Iam getting this error?Pls help me...

    Thanks,
    Jennie.
    if you have view container architecture then you can use this
    TKeyResponse CMainContainer:: OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
    {
    if(aType != EEventKey)
    {
    return EKeyWasNotConsumed;
    }

    switch(aKeyEvent.iCode)
    {
    case EKeyUpArrow:
    case EKeyDownArrow:
    {
    iList->OfferKeyEventL(aKeyEvent,aType);
    break;
    }

    case EKeyOK:
    {
    Select();
    break;
    }

    default:
    {
    return EKeyWasNotConsumed;
    }
    }
    return EKeyWasConsumed;
    }

    void CMainContainer::Select()
    {
    TInt i;
    i = iList->CurrentItemIndex();
    switch(i)
    {
    case 0:
    STATIC_CAST(CMyAppUi* ,CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ViewId1));
    break;

    case 1:
    STATIC_CAST(CMyAppUi* ,CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ViewId2));
    break;

    case 2:
    STATIC_CAST(CMyAppUi* ,CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ViewId3));
    break;

    default:
    break;
    }
    }


    and you can call this select function from the Option Softkey like you can define "Open" on left softkey

    hope this will work for you

Similar Threads

  1. Cannot read from listbox item array
    By Acemaker in forum Symbian C++
    Replies: 6
    Last Post: 2007-07-14, 17:43
  2. ListBox Errors
    By javadi82 in forum Symbian User Interface
    Replies: 7
    Last Post: 2006-11-08, 13:29
  3. Two listbox using the same container
    By ninidotnet in forum Symbian User Interface
    Replies: 1
    Last Post: 2006-05-16, 09:35
  4. open a view by clicking the listbox item
    By kirtij in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2006-02-24, 15:55
  5. How to delete the last item in a listbox
    By zhang_guoqing in forum Symbian User Interface
    Replies: 1
    Last Post: 2003-07-21, 07:28

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •