Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.android.helpmequit;
- import android.support.v7.app.ActionBarActivity;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.TextView;
- // This app is used to help people quit smoking
- public class MainActivity extends ActionBarActivity {
- //initialized variables for
- int daily = 0;
- int goal = 0;
- int wean = 0;
- public void increment_daily(View view) {
- daily = daily + 1;
- displayDaily(goal);
- }
- public void increment_goal(View view) {
- goal = goal + 1;
- displayGoal(goal);
- }
- public void increment_wean(View view) {
- wean = wean + 1;
- displayWean(wean);
- }
- public void decrement_daily(View view) {
- daily = daily - 1;
- displayDaily(goal);
- }
- public void decrement_goal(View view) {
- goal = goal - 1;
- displayGoal(goal);
- }
- public void decrement_wean(View view) {
- wean = wean - 1;
- displayWean(wean);
- }
- private void displayDaily(int number) {
- TextView dailyTextView = (TextView) findViewById(
- R.id.daily_text);
- dailyTextView.setText("" + number);
- }
- private void displayGoal(int number) {
- TextView goalTextView = (TextView) findViewById(
- R.id.goal_text);
- goalTextView.setText("" + number);
- }
- private void displayWean(int number) {
- TextView weanTextView = (TextView) findViewById(
- R.id.wean_text);
- weanTextView.setText("" + number);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement