Session 6 - Tutorial
Exercise 1
Create an app that allows you to enter 5 different tasks and then “tick” them off.
Once all 5 tasks are completed, display a message to congratulate the user.
Things to consider:
What Layout will you use?
What event listener will you use?
For assistance in the this app, I recommend you have a look at the JustJava app
example provided here:
Download JustJava
Extension:
Add a button that will reset all of the values.
Add functionality that will allow you to email completed lists to an email address of your choice
Exercise 2
Create another simple app that calculates how much of a tip you will leave based on
the price of your restaurant meal.
Ensure that you use a RadioGroup and Radio Buttons to achieve this functionality.
Things to consider:
What EventListener will you use?
How can you ensure that a user enters a number for the bill amount?
The following code snippets might of use to you:
EditText editTextBillAmount = null;
TextView textViewTipAmount = null;
RadioButton radioButtonTipTen = null;
RadioButton radioButtonTipFifteen = null;
RadioButton radioButtonTipTwenty = null;
RadioGroup rg = null;
DecimalFormat df = new DecimalFormat("£####.00");
editTextBillAmount = (EditText) findViewById(R.id.bill_amount);
textViewTipAmount = (TextView) findViewById(R.id.tip_amount);
radioButtonTipTen = (RadioButton)findViewById(R.id.ten);
radioButtonTipFifteen = (RadioButton)findViewById(R.id.fifteen);
radioButtonTipTwenty = (RadioButton)findViewById(R.id.twenty);
rg = (RadioGroup) findViewById(R.id.tip_choices);
rg.setOnCheckedChangeListener(this);
public void onCheckedChanged(RadioGroup rg, int i){
if(i==radioButtonTipTen.getId())
textViewTipAmount.setText(df.format(Double.parseDouble
(editTextBillAmount.getText().toString())*.10));
else if(........
}