BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-13-2009, 12:12 AM   #1 (permalink)
New Member
 
Join Date: Jun 2008
Model: 8707
PIN: N/A
Carrier: Vodafone
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question How t o get Clickevent for Labelfield or ListField in BlackBerry Device?

Please Login to Remove!

Hi,

I am newbei in the BlackBerry developement.
Please help me out to come out my problem ,coz it is urgent.
I have displayed my list of items by using Label Field and ListField both way.
Now i want the Clickevent on any of the item selected.
I have tried to search on the net and also i have tried my own methodology,but i was not able to get the clickevent.
I have also used trackwheelRoll() method when the trackball click but in that case how to get the listField item clickevent that i dont know.
If any body have any idea or solution,please provide with any code snippet or any useful link.
Thanking you with an anticipation in advance.
Offline  
Old 05-13-2009, 12:14 AM   #2 (permalink)
BBF Spam Killer Moderator
 
daphne's Avatar
 
Join Date: May 2007
Location: on a sunny beach
Model: Paspt
OS: 10.3.0.90
PIN: X1ZPY34K
Carrier: VZW but not for long
Posts: 9,176
Post Thanks: 120
Thanked 147 Times in 116 Posts
Default

**Moved to Developer Forum**
__________________
Report spam text messages to 7726
#BlackBerry by choice
Offline  
Old 05-13-2009, 08:12 AM   #3 (permalink)
New Member
 
Join Date: Oct 2008
Model: 8800
PIN: N/A
Carrier: rogers
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you are listing out a bunch of text items and want to scroll through the list and select stuff that results in some other action then there are probably better ways than to use a LabelField, you can implement fieldchangelistener on fields to detect the current selected field or leaf and then take some action after - or use the onNavigationclick method like this

public boolean navigationClick (int status , int time)
{
Field focus = UiApplication.getUiApplication().getActiveScreen() .getLeafFieldWithFocus();
if (focus instanceof BitmapField) {

do something
}
Offline  
Old 05-13-2009, 02:29 PM   #4 (permalink)
New Member
 
Join Date: May 2009
Model: 9300
PIN: N/A
Carrier: TMOBILE
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am facing the same problem
Offline  
Old 05-15-2009, 10:59 AM   #5 (permalink)
New Member
 
Join Date: Mar 2009
Model: 8100
PIN: N/A
Carrier: ATT
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Check out this tutorial on Field Change Listeners:
blackberrytutor.info/tutorial2.html
Offline  
Old 05-19-2009, 03:13 AM   #6 (permalink)
New Member
 
Join Date: Jun 2008
Model: 8707
PIN: N/A
Carrier: Vodafone
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot for your Valuable help.....
Really it works........
But in this case i am able to get the index of the ListField but if i want to access the Label(String of the Selected index of ListField) ,Then how should i get that value?

I have tried by my way as using the LiatCallBack method but in that case it is just returing the Object(Address) of that selected index ListField.

My code snippet is below:-


{code}
public boolean navigationClick(int status, int time) {
Field focus = list.getLeafFieldWithFocus();
Dialog.alert("Focus String :: " + focus.getIndex());

if (focus instanceof ListField) {
ListField listField=(ListField)focus;


Dialog.alert("Selected Index"+listField.getSelectedIndex());
Dialog.alert("Selected List Value"+listField.getCallback().get(listField, listField.getSelectedIndex()).toString());


}
return true;
}

{/code}

Please provide any code snippet or any Link or any Solution as i am stucked here only and i want to perform more operation on the Selected item String Value.

Thanks in advance.
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.