![]() |
How to determine which button is clicked? I'm a rookie at the BB stuff but an experienced developer. In looking at the samples and doing searches via Google, I've yet to come across an example of how to determine which of two buttons have been clicked with the trackwheel. I currently have the following code, modified from the Hello World sample: import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; class SalutationScreen extends MainScreen { public SalutationScreen() { super(); LabelField applicationTitle = new LabelField("Hello World Title"); ButtonField testButton = new ButtonField("Click Me", FOCUSABLE); ButtonField orButton = new ButtonField("Or Me", FOCUSABLE); setTitle(applicationTitle); add(testButton); add(orButton); } public boolean onClose() { Dialog.alert("Bye World!"); System.exit(0); return true; } // Invoked when the trackwheel is clicked. public boolean trackwheelClick( int status, int time ) { Dialog.alert("Button clicked. Status:" + status) ; return true; } } Along with the associated HelloWorld.java routine. How do I determine which button was clicked? Thanks in advance for the help. Tim |
use a field change listener. |
Duh! How about an example? Or at least point me to a sample that demonstrates how this works with multiple buttons. |
Well, I finally figured this out. I'm surprised that something that should be so easy to do was so difficult to figure out. I guess it's due to the fact that I'm a C & C# developer, just now getting into java. Plus, the fact that the BB does things a little differently. Anyway, for the benefit of anyone else trying to figure this out, here's my sample code for determing which button is being selected. Enjoy. Code: // HelloWorld.javaCode: //SalutationScreen.java |
| All times are GMT -5. The time now is 05:54 AM. |
Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.