3.5. Adding Functionality to the App
Class MainActivity
(Figs. 3.9–3.16) implements the Tip Calculator app’s functionality. It calculates the 15% and custom percentage tips and total bill amounts, and displays them in locale-specific currency format. To view the file, open src/com.deitel/tipcalculator
and double clck MainActivity.java
. You’ll need to enter most of the code in Figs. 3.9–3.16.
1 // MainActivity.java 2 // Calculates bills using 15% and custom percentage tips. 3 package com.deitel.tipcalculator; 4 5 import java.text.NumberFormat; // for currency formatting 6 7 import android.app.Activity; // base class for activities 8 import android.os.Bundle; // for saving state information 9 import ...
Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.