Welcome!

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

Reply
Contributor
lostdragon
Posts: 34
Registered: ‎10-03-2012
My Device: 9300
My Carrier: cell c
Accepted Solution

FieldList selection

Hi

Iam trying to select items from a list.
I created the list using the following code.

MyList= new ObjectListField();
MyList.set(myarray);
Add(MyList);

My problem is how do I select the items in mylist. Thank you in advance.
Please use plain text.
Developer
simon_hain
Posts: 15,947
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: FieldList selection

i assume you have the list displayed on the screen and are contempt with that?

there is no direct accessor method in the API, usually you use navigationClick for it.
use getSelectedIndex to retrieve the index of the clicked object, and get the object from your array.
----------------------------------------------------------
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
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: FieldList selection

ListField does not generate events on clicks, which is typically what you want to get a selection.  This code might help:

 

http://supportforums.blackberry.com/t5/Java-Development/Implementing-Listener-for-Custom-ListField/m...

 

then you can, in your change listener, use the getSelectedIndex to find out which of your entries was in focus. 

 

Hopefully that will get you going. 

Please use plain text.