January 2014
Intermediate to advanced
736 pages
70h 43m
English
Lines 20–32 of Fig. 3.11 declare class MainActivity’s variables. The NumberFormat objects (lines 20–23) are used to format currency values and percentages, respectively. NumberFormat static method getCurrencyInstance returns a NumberFormat object that formats values as currency using the device’s default locale. Similarly, static method getPercentInstance formats values as percentages using the device’s default locale.
The bill amount entered by the user into amountEditText will be read and stored as a double in billAmount (line 25). The custom tip percentage (an integer in the range 0–30) that the user sets by moving the Seekbar thumb will be multiplied by 0.01 to create a double for use in calculations, ...
Read now
Unlock full access