BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 12-18-2007, 11:56 AM   #1
oblivion
New Member
 
Join Date: Aug 2007
Model: 7100T
PIN: N/A
Carrier: cingular
Posts: 11
Default Getting the selected index from a ChoiceField

Please Login to Remove!

Hi everyone, I ran into a problem that seems easy but I could not yet figure out how to solve. I have a ObjectChoiceField and a button. The visibility of the button should be determined based on the selected value of the ChoiceField. If the last item in the ChoiceField is selected, the button should not be visible. But as soon as the user changes the selection (from the last one to any other one), the button should be visible again. I figured that the easiest way to do this is to implement a FieldChangeListener on the ChoiceField and when the selection changes from the last one to another, just add the button to the manager. However, the fieldChanged method on the listener interface is called anytime the user scrolls through the choices (without clicking on the trackwheel to change the actual selection). I need to make the button visible only if the selection actually changes. I tried to override the navigationclick and navigationunclick on the choicefield to understand when the user actually clicks on the trackwheel (trackwheelclick and trackwheelunclick can also be used) but the problem with those methods is that they do not capture the final trackwheel click to change the selection. I mean, when you first click on the choicefield, navigationclick and then navigationunclick is invoked, and after you scroll through the choices and click on the trackwheel again to change the selection, no method is invoked. Because of this I can not figure out whether the user actually changed the selection and can not update the button accordingly. I hope I was able to explain everything Is there anyone to throw any ideas?

Thanks!
Offline  
Old 12-19-2007, 04:22 AM   #2
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

how about ChoiceField.getSelectedIndex()? You can check it whenever your changelistener fires.

hth,
simon
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 12-20-2007, 10:41 AM   #3
oblivion
New Member
 
Join Date: Aug 2007
Model: 7100T
PIN: N/A
Carrier: cingular
Posts: 11
Default

yeah i'm already using getSelectedIndex() to get the selection but the source of my problem is the timing of the changelistener fires. it fires BEFORE the user clicks on the trackwheel to actually change the selection. so if you have 3 items and scroll through them without changing the current selection, the changelistener is notified 3 times. if i was able to distinguish between a trackwheel click that opens the selections and a trackwheel click that actually changes the selection, i would be fine. but since this is not the case, i cant figure out a solution.
Offline  
Old 12-20-2007, 03:59 PM   #4
vph
Knows Where the Search Button Is
 
Join Date: Dec 2007
Model: 8700
PIN: N/A
Carrier: Cingular
Posts: 35
Default

I got into similar problem, and here is my solution

if( context == FieldChangeListener.PROGRAMMATIC ) { // this happens when users scroll
...
} else { // this happens when users select it

....
}


--vph
Offline  
Old 12-21-2007, 11:33 AM   #5
oblivion
New Member
 
Join Date: Aug 2007
Model: 7100T
PIN: N/A
Carrier: cingular
Posts: 11
Default

thanks, i've tried that. but for some reason, the context is always non-programmatic, both for a scroll or selection.
Offline  
Old 02-12-2009, 12:08 PM   #6
simmayor
New Member
 
Join Date: Feb 2009
Model: .
PIN: N/A
Carrier: .
Posts: 1
Default

Check context == ChoiceField.CONTEXT_CHANGE_OPTION
Offline  
Old 02-16-2009, 10:29 AM   #7
lionscribe
Knows Where the Search Button Is
 
Join Date: Feb 2008
Model: none
Carrier: sprint
Posts: 24
Default

Wirelessly posted

I believe that when scrolling the context equals "0", and when selecting it equals "2". It may be the opposite. I don't know what the values mean, but it worked by me.
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


10-Count GE Fluorescent Ballast, GE432-MVPS-L Electronic T8, 120v to 277v picture

10-Count GE Fluorescent Ballast, GE432-MVPS-L Electronic T8, 120v to 277v

$108.99



4 Count Case GE ProLine 2 Bulb 120V T12 Electronic Fluorescent Light Ballasts picture

4 Count Case GE ProLine 2 Bulb 120V T12 Electronic Fluorescent Light Ballasts

$49.99



Keystone Replacement Ballast KTEB-432RIS-1-TP-SL Value Pack - (2 Ballast Pack) picture

Keystone Replacement Ballast KTEB-432RIS-1-TP-SL Value Pack - (2 Ballast Pack)

$39.78



Inter-Global IG13-20EL electronic ballast 120v New Common Aquarium Light Ballast picture

Inter-Global IG13-20EL electronic ballast 120v New Common Aquarium Light Ballast

$19.95



Philips ADVANCE AmbiStar RELB-2S40-N Replacement Ballast 40-Watt 2-Lamp T12 picture

Philips ADVANCE AmbiStar RELB-2S40-N Replacement Ballast 40-Watt 2-Lamp T12

$18.79



QHE 4X32T8/UNV ISH-SC Sylvania 51347 4-Lamp T8 Instant Start Fluorescent Ballast picture

QHE 4X32T8/UNV ISH-SC Sylvania 51347 4-Lamp T8 Instant Start Fluorescent Ballast

$9.00







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