Advertisement
Guest User

menuGMD

a guest
Sep 20th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. package com.example.doanshop;
  2.  
  3. import android.content.Intent;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.TextView;
  8. import android.widget.Toast;
  9.  
  10. public class MenuActivity extends AppCompatActivity {
  11.  
  12. private int mAddm3 = 0;
  13. public TextView mAddCount;
  14.  
  15. private int mAddms = 0;
  16. public TextView mAddCountS;
  17.  
  18. private int mAddmx = 0;
  19. public TextView mAddCountX;
  20.  
  21. @Override
  22. protected void onCreate(Bundle savedInstanceState) {
  23. super.onCreate(savedInstanceState);
  24. setContentView(R.layout.activity_menu);
  25. mAddCount = (TextView) findViewById(R.id.subtotal_countm3);
  26. mAddCountS = (TextView) findViewById(R.id.subtotal_countms);
  27. mAddCountX = (TextView) findViewById(R.id.subtotal_countmx);
  28. }
  29.  
  30.  
  31.  
  32. public void add_model3(View view){
  33. mAddm3++;
  34. if (mAddCount != null){
  35. mAddCount.setText(Integer.toString(mAddm3));
  36. }
  37. }
  38.  
  39. public void remove_model3(View view){
  40.  
  41. if(mAddm3 <= 0){
  42. mAddm3 = 0;
  43. Toast.makeText(this, "Can't remove anymore.", Toast.LENGTH_SHORT).show();
  44. }else {
  45. mAddm3--;
  46. mAddCount.setText(Integer.toString(mAddm3));
  47. }
  48.  
  49. }
  50.  
  51.  
  52. public void add_models(View view){
  53. mAddms++;
  54. if (mAddCountS != null){
  55. mAddCountS.setText(Integer.toString(mAddms));
  56. }
  57. }
  58.  
  59. public void remove_models(View view){
  60.  
  61. if(mAddms <= 0){
  62. mAddms = 0;
  63. Toast.makeText(this, "Can't remove anymore.", Toast.LENGTH_SHORT).show();
  64. }else {
  65. mAddms--;
  66. mAddCountS.setText(Integer.toString(mAddms));
  67. }
  68.  
  69. }
  70.  
  71. public void add_modelx(View view){
  72. mAddmx++;
  73. if (mAddCountX != null){
  74. mAddCountX.setText(Integer.toString(mAddmx));
  75. }
  76. }
  77.  
  78. public void remove_modelx(View view){
  79.  
  80. if(mAddmx <= 0){
  81. mAddmx = 0;
  82. Toast.makeText(this, "Can't remove anymore.", Toast.LENGTH_SHORT).show();
  83. }else {
  84. mAddmx--;
  85. mAddCountX.setText(Integer.toString(mAddmx));
  86. }
  87.  
  88. }
  89.  
  90. public void openCheckout(View view) {
  91. Intent intent1 = new Intent(this, CheckoutActivity.class);
  92.  
  93. Bundle bundle = new Bundle();
  94. bundle.putString("model3",String.valueOf(mAddm3));
  95. bundle.putString("modelS",String.valueOf(mAddms));
  96. bundle.putString("modelX",String.valueOf(mAddmx));
  97. intent1.putExtras(bundle);
  98. intent1.putExtras(bundle);
  99. intent1.putExtras(bundle);
  100. startActivity(intent1);
  101.  
  102. }
  103.  
  104.  
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement