Vikas
Vikas

Reputation: 804

adding a listener to a listField in BlackBerry

I am working on BB OS v5.0, 8520. I have managed to get the list to appear on the screen. I am using a String Array and adding it into a Vector. Now I want to find out onclick, which is the item that is clicked and accordingly perform some operation. for the time being lets just say i want to throw an alert. any help..

Upvotes: 2

Views: 1033

Answers (2)

Vit Khudenko
Vit Khudenko

Reputation: 28418

In your ListField you should override navigationClick(int status, int time). Then inside of the navigationClick() get the selected item index via ListField.getSelectedIndex() and do what ever you need with it.

Note, you don't need to override touchEvent(TouchEvent message), because navigationClick() is called by BB framework regardless of whether the click event is originated by a touch-screen event or a trackball(pad) event. So the code will work for any screen type.

Upvotes: 5

Tamar
Tamar

Reputation: 2066

How are you displaying the strings and making them clickable?

You could extend LabelField, override the trackwheelClick or touchEvent methods and do what you want there.

Upvotes: 0

Related Questions