I looked at your code and nothing blatantly wrong jumped out at me. However, I wouldn't designate the main application class the duties of being the FieldChangeListener. It's not something it should have to be aware of.
The best I can do for you is provide an example app that implements the FieldChangeListener interface for a ButtonField. It's not a solution but maybe with your better knowledge of your code you'll be able to pick something out that is different than this example. Hope it helps.
I looked at your code and nothing blatantly wrong jumped out at me. However, I wouldn't designate the main application class the duties of being the FieldChangeListener. It's not something it should have to be aware of.
The best I can do for you is provide an example app that implements the FieldChangeListener interface for a ButtonField. It's not a solution but maybe with your better knowledge of your code you'll be able to pick something out that is different than this example. Hope it helps.
Import net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api.ui. Field; import net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api.ui. UiApplication; import net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api.ui.container.
MainScreen; import net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api.ui.component. Dialog; import net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api.ui.component. LabelField; import net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api.ui.component.
ButtonField; import net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api" rel="nofollow">net.rim.device.api.ui. FieldChangeListener; /** * Test implementation of ButtonField. */ public class TestAppMain extends UiApplication { /** * Default Constructor.
*/ private TestAppMain() { pushScreen(new AppScreen()); } /** * App entry point. * @param args Arguments. */ public static void main(String args) { TestAppMain app = new TestAppMain(); app.
EnterEventDispatcher(); } /** * Main application screen. */ private static class AppScreen extends MainScreen { /** * Default constructor. */ public AppScreen() { LabelField title = new LabelField("Button Test Demo", LabelField.
ELLIPSIS | LabelField. USE_ALL_WIDTH); setTitle(title); // Create a button with a field change listener. FieldChangeListener listener = new FieldChangeListener() { public void fieldChanged(Field field, int context) { ButtonField buttonField = (ButtonField) field; System.out.
Println("Button pressed: " + buttonField.getLabel()); } }; ButtonField buttonField = new ButtonField("Test Button", ButtonField. CONSUME_CLICK); buttonField. SetChangeListener(listener); add(buttonField); } /** * Handle app closing.
*/ public void close() { Dialog. Alert("Goodbye! "); System.
Exit(0); super.close(); } } }.
Nods Yeah, that's the other way I was doing it. I am however, really confused as to how much goes in the screen itself, vs. methods in the main code. A lot of the tutorials BB provided leave the screen mostly blank.It does make a lot of sense to do things in screen, though.
– Jenny Sep 17 '09 at 14:27.
I agree with Fostah(+1), it's common to implement FieldChangeListener in Field, Manager or Screen, or use a standalone FieldChangeListener. Also, to push/pull screen from Field: UiApplication. GetUiApplication().
PushScreen(nextScreen); See How to navigate back to the previous screen in the Blackberry emulator?
Hrrm...trying to do this makes my print statement succesfully print (hooray! ), but the program crashes harder. Before, it went to that white error screen with the ""JUM Error 104: Uncaught NullPointer Exception", but nothing would actually kick me out (I could hit 'continue' and keep running my program.
NOW, however, it kicks me into the debug perspective in eclipse. If I undo my code changes to get it back to how it was, it's still doing this, which confuses me. – Jenny Sep 17 '09 at 14:56 calling ANY method within the listener crashes it to the debug screen for "Screen.
Class", as well. I figure I'll refactor all of my code to make the brunt of the work happen in my providerScreen class, then see what happens. – Jenny Sep 17 '09 at 15:11 When you find reason and solution, it will be great to have your answer.
– Max Gontar Sep 17 '09 at 17:12 sigh I can get the listener to work properly in a new class, with no code in it other than the button and listener. However, if I comment EVErYTHING out but a test button and listener in my original class, it still crashes. It's so confusing.
– Jenny Sep 18 '09 at 14:46 Huh. So, I tried to refactor things, and noticed that the meat of the work was in the Screen class in the example Fostah gave. However, if I try to emulate this, my code crashes on startup, without getting anywhere, saying that there's something wrong with Connection.
Can you just not do HTTPConnections from screens? – Jenny Sep 18 '09 at 15:20.
I'm super confused, but I managed to fix things. I created a new class from scratch, and then just copied and pasted my old code into it. Everything works.
The only thing I changed was only importing classes that Eclipse said was necessary (before I had some import statements from various tutorials, etc. So some were possibly not being used. ) Is it possible I was importing something that was causing things to crash? I really would rather have most of my code in the screen itself, but trying that crashes the whole thing before I can even load.
Something about the xml parser I'm using not being happy. pastie.org/621932 There's the modified code. I'm really frustrated, because I know that there is some inherent UNDERSTANDING of this frame work that I'm not grokking, and that most of my troubles are coming from this.
I suppose only practice will help me, though.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.