Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. package com.example.android.helpmequit;
  2.  
  3. import android.support.v7.app.ActionBarActivity;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.TextView;
  8.  
  9. // This app is used to help people quit smoking
  10. public class MainActivity extends ActionBarActivity {
  11.  
  12. //initialized variables for
  13. int daily = 0;
  14. int goal = 0;
  15. int wean = 0;
  16.  
  17. public void increment_daily(View view) {
  18. daily = daily + 1;
  19. displayDaily(goal);
  20. }
  21. public void increment_goal(View view) {
  22. goal = goal + 1;
  23. displayGoal(goal);
  24. }
  25. public void increment_wean(View view) {
  26. wean = wean + 1;
  27. displayWean(wean);
  28. }
  29.  
  30. public void decrement_daily(View view) {
  31. daily = daily - 1;
  32. displayDaily(goal);
  33. }
  34. public void decrement_goal(View view) {
  35. goal = goal - 1;
  36. displayGoal(goal);
  37. }
  38. public void decrement_wean(View view) {
  39. wean = wean - 1;
  40. displayWean(wean);
  41. }
  42.  
  43. private void displayDaily(int number) {
  44. TextView dailyTextView = (TextView) findViewById(
  45. R.id.daily_text);
  46. dailyTextView.setText("" + number);
  47. }
  48. private void displayGoal(int number) {
  49. TextView goalTextView = (TextView) findViewById(
  50. R.id.goal_text);
  51. goalTextView.setText("" + number);
  52. }
  53. private void displayWean(int number) {
  54. TextView weanTextView = (TextView) findViewById(
  55. R.id.wean_text);
  56. weanTextView.setText("" + number);
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement