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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

BlackBerry® World™ Development

Reply
New Contributor
gbgas001
Posts: 7
Registered: ‎01-10-2012
My Carrier: Vodaphone
Accepted Solution

Fault with 9800 java? .getLabel not working

.getLabel not working on 9800 Hi    im having problems with a button that fires a timer, If i take away all the "if" statements it works fine so there is nothing wrong witht the timer code. This same code works fine in every other phone i have tried 8900, storm, etc its only on the 9800 that it fails and runs to the end of the "if" statements.   is there a change in the .getLabel?   my code is...     startbtn.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field1, int context) { /////sound file try { Manager.playTone(ToneControl.C4, 100, 50); } catch (MediaException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (startbtn.getLabel() == "START"){ startbtn.setLabel("STOP!"); startTimer(); } else if (startbtn.getLabel() == "STOP!"){ startbtn.setLabel("RESET"); stopTimer(); } else if (startbtn.getLabel() == "RESET"){ dismiss(); //// RESET SCREEN AFTER } }});     i hope someone can help i cant find an answer anywhere.
Please use plain text.
Developer
adwiv
Posts: 260
Registered: ‎08-01-2008

Re: Fault with 9800 java? .getLabel not working

Lesson To Learn:

 

NEVER, I mean NEVER, compare strings for equality using the == operator.

 

http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java

Please use plain text.
New Contributor
gbgas001
Posts: 7
Registered: ‎01-10-2012
My Carrier: Vodaphone

Re: Fault with 9800 java? .getLabel not working

Thank you so much, I have been looking for an answer for ages... I just didn't ask the correct Question..
Please use plain text.