Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

New Developer
Posts: 4
Registered: ‎02-10-2010
My Device: Storm 2

Problem in implementing list..



I am trying to implement the listfield by following the following steps.. but i am not a able to implement.. can u plz write the code by following the steps so that i can see how things go and compare it with my code..



Create a list boxUse a list box to display a list from which users can select one or more values.

1. Import the following classes:•


java.lang.String• net.rim.device.api.ui.component.ListField•



2. Import the net.rim.device.api.ui.component.ListFieldCallback interface.


3. Create a class that implements the ListFieldCallback interface.


private class ListCallback implementsListFieldCallback {


4. Create the items that you want to display in a ListField.


String fieldOne = new String("Marco Cacciacarro");

String fieldTwo = new String("Meredith Wagler");


5. Create an instance of a ListField.


ListField myList = new ListField(0,ListField.MULTI_SELECT);


6. Create an instance of a ListCallback.


ListCallback myCallback = new ListCallback();


7. Set the call back of the ListField to be the ListCallback.




8. Use the ListCallBack object to add items to the ListField.


myCallback.add(myList, fieldOne);

myCallback.add(myList, fieldTwo);


9. Add the ListField to the MainScreen.mainScreen.add(myList);




Posts: 17,005
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Problem in implementing list..

the callback has to store the elements.




feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter