Advertisement
st_1979

Activity1 targil2

Apr 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.08 KB | None | 0 0
  1. package com.example.stas.targil2;
  2.  
  3.  
  4.  
  5. import android.content.Intent;
  6. import android.support.v7.app.AppCompatActivity;
  7. import android.os.Bundle;
  8. import android.view.View;
  9. import android.widget.CheckBox;
  10. import android.widget.EditText;
  11. import android.widget.ImageView;
  12. import android.widget.RadioButton;
  13. import android.widget.RadioGroup;
  14. import android.widget.TextView;
  15. import android.widget.Toast;
  16. import android.widget.Button ;
  17.  
  18.  
  19. public class Activity1 extends AppCompatActivity {
  20.  
  21.  
  22.     private  EditText enterText;
  23.     private TextView print;
  24.     public static String SELECTED_ITEM;
  25.     private Button Back ;
  26.     private Button Next ;
  27.     @Override
  28.     protected void onCreate(Bundle savedInstanceState) {
  29.         super.onCreate(savedInstanceState);
  30.         setContentView(R.layout.activity_1);
  31.  
  32.         enterText= findViewById(R.id.userName1);
  33.         print = findViewById(R.id.print1);
  34.  
  35.         if (SELECTED_ITEM != null) {
  36.             print.setText(SELECTED_ITEM);
  37.         }
  38.  
  39.         //--
  40.  
  41.         Next= findViewById(R.id.button1);
  42.         Back = findViewById(R.id.button2);
  43.  
  44.         View.OnClickListener onClicker = new View.OnClickListener() {
  45.             @Override
  46.             public void onClick(View v) {
  47.  
  48.                 // doing something
  49.                 switch(v.getId()){
  50.                     case R.id.button2 :goBeck(v);
  51.                         break;
  52.                     case R.id.button1 :goNext(v);
  53.                         break;
  54.                 }
  55.  
  56.             }
  57.  
  58.         } ;//
  59.  
  60.         Back.setOnClickListener(onClicker);
  61.         Next.setOnClickListener(onClicker);
  62.  
  63.         //--
  64.  
  65.     }
  66.  
  67.  
  68.  
  69.     public void goNext(View v) {
  70.  
  71.         Activity2.SELECTED_ITEM =enterText.getText().toString();
  72.         Intent intent = new Intent(this,Activity2.class);
  73.         startActivity(intent);
  74.         finish();
  75.  
  76.     }
  77.  
  78.  
  79.     public void goBeck(View v) {
  80.  
  81.          Main.SELECTED_ITEM =enterText.getText().toString();
  82.         Intent intent = new Intent(this, Main.class);
  83.         startActivity(intent);
  84.         finish();
  85.  
  86.     }
  87.  
  88.  
  89.  
  90.  
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement