You can continue by adding the constructor for the screen and setting up the rest of the fields. This constructor does a number of things to set up the screen. In general, it is creating and adding all of the screen elements that will be displayed.
1. Add the following code to the
TipCalcMainScreen
class.public TipCalcMainScreen() { // Each screen can have a field in the Title section. LabelField title = new LabelField("TipCalc" , LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH); // Set the title to the label. setTitle(title); // setup the EditField to accept the Bill Amount amount.setLabel("Bill Amount: $"); // add the field to the screen add(amount); }
2. Add the
calculateTip
method to theTipCalcMainScreen
class.protected double calculateTip() { double billamount; // Convert the text entered into the textfield into // a floating point number. try { billamount = Double.valueOf( amount.getText().trim()).floatValue(); } catch (NumberFormatException...