07-14-2011 11:52 AM
Hi, I'm following the user interface tutorial here:
http://supportforums.blackberry.com/rim/attachment
When I run the program in a simulator it seems to run fine until I attempt to change a capital. When I do, I get a null pointer exception in this block of code:
private MenuItem _changeCapital = new MenuItem("Change Capital", 110, 10) {
public void run() {
if (displayed == 0)
_canadaCapital = _input.getText();
else if (displayed == 1)
_ukCapital = _input.getText();
else if (displayed == 2)
_usCapital = _input.getText();
}
};It seems to be _input.getText(); is returning a null value. _input is a BasicEditField, and the field I think it references does have text in it. Also, it successfully sets the text in other locations in the code with _input.setText().
My code is currently unmodified. It's simply a cut&paste from the tutorial. Can someone fill me in on what the problem is?
My only potential lead is a warning that _changeCapital is being initialized with a deprecated constructor.
I can't see why that would matter though. Oh yes, also _input is a different color (blue) in my IDE on the getText() lines, compared to the setText() lines (black). I'm new to Eclipse, so I don't know what that means.
Thanks for any help!
07-18-2011 01:38 PM
07-18-2011 03:45 PM
If you're using the code copied from that PDF, make sure you aren't mixing "_input" and "input" (they use "input").
07-18-2011 03:56 PM
Yeah, I don't see anywhere in that tutorial where they use 'input' instead of '_input'.
07-18-2011 04:00 PM
Pages 11, 12, 14 (use both on this page actually), 15, and 16
07-18-2011 04:13 PM
I realize you're trying to help, so want to be rude, but... are we looking at the same source?
On the pages you mention, I see nothing but _input variables. For example, from various lines on page 11:
BasicEditField _input;
_input = new BasicEditField("Capital (can be changed): ", _capital);
_fieldManagerMiddle.add(_input);
_input.setText(_canadaCapital);
_input.setText(_ukCapital);
Perhaps your pdf viewer isn't rendering underscores properly?
07-18-2011 04:23 PM
Apparently it is not rendering some of the _'s for me...interesting