about ListBox selection.......
| Wed, 2005-08-10 08:04 | |
|
i have created the ListBox but i cann't nevigate the items using arrow key. my code is given below:
.rss RESOURCE LISTBOX r_akntalist_single_1 { array_id = r_akntalist_item_single1; flags = EAknListBoxSelectionList; //flags = EAknListBoxMarkableList; } RESOURCE ARRAY r_akntalist_item_single1 { items = { LBUF { txt = "1\tItem1"; }, LBUF { txt = "2\tItem2"; }, LBUF { txt = "3\tItem3"; }, LBUF { txt = "4\tItem4";} };  } mycontainer.cpp void mycontainer::ConstructL(const TRect& aRect)   {   CreateWindowL();   TInt resourceId = R_AKNTALIST_SINGLE_1; iListBox = new(ELeave)CAknSingleNumberStyleListBox(); iListBox->SetContainerWindowL( *this); TResourceReader reader; CEikonEnv::Static()->CreateResourceReaderLC(reader, resourceId); iListBox->ConstructFromResourceL( reader ); CleanupStack::PopAndDestroy(); // resource stuffs. SizeChanged(); iListBox->ActivateL(); DrawNow();   SetRect(aRect);   ActivateL();   } TInt mycontainer::CountComponentControls() const   {   return 1;   } CCoeControl* mycontainer::ComponentControl(TInt aIndex) const   {   switch(aIndex) { case 0: return iListBox; default: return NULL; }   } void mycontainer::SizeChanged()   { iListBox->SetExtent (TPoint(0,0), iListBox->MinimumSize());   } it is displaying the Items and select the Item1. i want to go Item2 or Item3........ but i cann't i am beginner. i am just learning. pls show some ways to do this thanks bashar  |
|






Forum posts: 142
yucca
Forum posts: 27
pls specify
thks
bashar
Forum posts: 2006
You won't learn if you expect people to post the exact snippet of code that you require.
Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant
Forum posts: 27
thanks i have solved the problem now i can navigate the ListBox items
now i want to know how can i go in "Item 1"(one of ListBox item) by pressing ok
anybody can help?
thanks
bashar
Forum posts: 192
Forum posts: 27
sorry i cann't agree with u. i want some suggestions not source code. if u know the right way then just inform me about that. thats all.
anyway thanks again for your attention
bashar
Forum posts: 192
{
return iListBox->OfferKeyEventL(aKeyEvent, aType);
}
Forum posts: 176
* Called by the framework whenever a list event occurs for which this container
* is an observer.
* @param aListBoxEvent The type of event which occured
*
*/
void CMyContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
{
// if the Select Key has been pressed
if ((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) || (aListBoxEvent == MEikListBoxObserver::EEventItemClicked)) {
if (iMyListBox) {
// Do something with ...
//...((*iMyList)[iMyListBox->CurrentItemIndex()]);
}
}
}
}
regards;
CG
Forum posts: 27
previously i used resource file for the ListBox now i want without resource. i have changed my code but it gives linking error
how can i solve
code:
iListBox = new (ELeave) CAknSingleNumberStyleListBox();
iListBox->SetContainerWindowL(*this);
iListBox->ConstructL(this,EAknListBoxSelectionList);
CDesC16Array* array = new (ELeave) CDesCArray(5 ); //here gives the error message
CleanupStack::PushL(array);
array->AppendL(_L("1\tItem1"));
array->AppendL(_L("2\tItem2"));
array->AppendL(_L("3\tItem3"));
array->AppendL(_L("4\tItem4"));
array->AppendL(_L("5\tItem5"));
CleanupStack::Pop();
iListBox->Model()->SetItemTextArray(array);
  SetRect(aRect);
  ActivateL();
where is the problem?
i have included
#include "MyFirstAppContainer.h"
#include <eiklabel.h>Â // for example label control
#include <aknlists.h>
#include <badesca.h>
pls someone give the response
thks
bashar
Forum posts: 176
Try CDesCArrayFlat instead;
Bye;
CG
Forum posts: 27
i have solved that problem
bashar
Forum posts: 36
Mr Bashar. please expalin me what will be the code in Ui.cpp. Iam very much canfused. My application is getting closed (program closed) as we run the application in the emeulator.
where I have went wrong?