The onTextChanged
method (lines 126–144) is called whenever the text in the amount-EditText
is modified. The method receives four parameters. In this example, we use only CharSequence s
, which contains a copy of amountEditText
’s text. The other parameters indicate that the count
characters starting at start
replaced previous text of length before
.
Line 133 converts the user input from amountEditText
to a double
. We allow users to enter only whole numbers in pennies, so we divide the converted value by 100.0 to get the actual bill amount—e.g., if the user enters 2495, the bill amount is 24.95. Lines 142–143 call updateStandard
and updateCustom
to recalculate and display the tips and totals.
18.220.73.87