glaukon
Android Tip Calculator
Last updated: 6/30/2013
Note: If you have not completed the Android Development Setup tutorial yet, and this is your first time writing for Android, you may need to take a look at that. It describes how to set up the programs and tools we need to write Android apps.
This tutorial will assume no knowledge of Java, and indeed, programming in general. It is the first in a series of progressively more complex Android tutorials I intend to make.
I think a tip calculator is an ideal first project for any Android initiate. It's simple, sure, but that's a good thing. It'll let us focus on familiarizing ourselves with the syntax and norms of Android Java. The tip calculator we will be building is a clone of my Just The Tip app, which you can download for free from the Play Store to try out.
The finished project files can be found here.
We plan out what features our tip calculator will have. It's always important to do some brainstorming before starting to program.
We finish planning out the tip calculator by creating a rough outline of how it will look.
We start to make the UI for our app, but then get wrapped up in a light discussion about object-oriented programming.
We learn about different layouts and Views, and set the ground work for the rest of the UI.
We make sure the UI elements all fit on the screen and are aligned properly.
We make a line. Yup, that's pretty much it.
We start to speed up now, and focus on XML. We make the tip and tax portions of the UI here.
We get pretty close to finishing the UI by adding the grand total and bill splitting portions of the app.
We finally finish the UI for our tipping calculator. At this point, you should feel pretty familiar with XML and the Graphical Layout tab of Eclipse.
We go over the automagically generated code Eclipse provides for us when we create a project.
We add functionality to the addDinerButton ImageButton that allows the user to add new rows to mainTable if they're eating out with friends. We also go over interfaces.
We speed it up a bit and start blasting through some Java, improving addDinerButton's functionality significantly.
We start to implement the bill splitting part of our app, but run into issues we'll need to fix in the next part.
We create a new class called Diner that will help us organize all the information about any one particular diner into one useful object.
We combine the Diner class with ArrayLists to finally solve the addDinerButton problem from Part 4.
We let the user change the name of Diner objects by means of a for loop and the onFocusChangeListener interface.
We go over the for loop a little more before moving on.
We start working on the buttons that add new orders for the Diners.
We fix the issues with the new order ImageButtons using for loops again.
We start working on getting the math to work.
We work on the updateTotal method for the Diner class.
We learn how the String.format method works, and use it to format a TextView's Text.
We learn how to use the Debug perspective to find bugs.
We use the replace method to fix the bug we just found.
We start messing around with the SeekBar to get the tip to work.
We get another step closer to finishing the tip calculation code.
We use method overloading to get our app to update calculations in real-time when the user changes the SeekBar.
We finish up the tip functionality by allowing the user to change the tip with an EditText instead of the SeekBar.
We start working on the grand total calculations.
We do some more debugging, this time with the System.out.println method.
We start getting the last part of our tip calculations to work: the tax.
We finish up with the tax calculations.
Just checking in...
We'll work on some of the features that, while not absolutely necessary, do give the app a bit more flavor.
We add a random name generator.