- Start Android Studio, Create new Project
- Briefly explain the IDE/simulator
- Go to
activity_main.xml
, explain difference between Text vs. Design view- Explain layout (currently uses
RelativeLayout
, we could probably useConstraintLayout
) - Add EditText for entering the Bill total
- Add SeekBar for controlling tip amount
- Set the min at 0, max at 100, and initial progress at 18 (for 18% tip)
android:min="0" android:progress="18" android:max="100"
- Set the min at 0, max at 100, and initial progress at 18 (for 18% tip)
- Add three TextViews
- One for showing tip percentage as the user moves the SeekBar
- One for showing the actual tip amount in dollars
- One for showing the final total
- Add a Button for navigating to the SplitActivity
- Explain layout (currently uses
- Go to
MainActivity.java
- Add binding for the components in XML (i.e. EditText, SeekBar, etc)
- Add double variables for tip, bill total, final total
private double billTotal; private double tip; private double total;
- Add event listener for SeekBar
tipSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {...
- Add logic within event handler to update textviews based on tip percentage being changed
- Add event listener for bill total EditText
totalEditTxt.addTextChangedListener(new TextWatcher() {...
- Add logic within event handler to update textviews based on bill total being changed
- Add event listener for button to navigate to SplitActivity
- Create a new Activity
SplitActivity
. Go to the XML and...- Add EditText for entering the number of people in the party
- Add three TextViews
- One for showing the original bill, split between the party
- One for showing the tip total, split between the party
- One for showing the final total, split between the party
- Go to
SplitActivity.java
- Add binding for the components in XML (i.e. EditText, TextView, etc)
- Add double variables for tip, bill total, final total from the first Activity and variables for current activity to compute the split
private double billTotal, tipTotal, finalTotal; private int numPeople; private double billPerPerson, tipPerPerson, totalPerPerson;
- Add event listener for number of people EditTxt
totalEditTxt.addTextChangedListener(new TextWatcher() {...
- Add logic within event handler to update textviews based on the number of people changing
- Add event listener for done button
doneBtn.setOnClickListener(new View.OnClickListener() {...
- Add logic within event handler to go back to first activity if user is finished
- Refactor event handler code with new methods so that repeated code can be removed
-
Notifications
You must be signed in to change notification settings - Fork 0
openwebbu/intro-android-spr18
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published