Advertisement
Shishu

next to previes in java

Oct 18th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. 1st activity of java
  2. public class MainActivity extends AppCompatActivity {
  3.      Button bnext;
  4.     @Override
  5.     protected void onCreate(Bundle savedInstanceState) {
  6.         super.onCreate(savedInstanceState);
  7.         setContentView(R.layout.activity_main);
  8.  
  9. bnext =(Button) findViewById(R.id.b1);
  10.         bnext.setOnClickListener(new View.OnClickListener() {
  11.             @Override
  12.             public void onClick(View v) {
  13.                 Intent a =new Intent(MainActivity.this,second.class);
  14.                 startActivity(a);
  15.                 finish();
  16.             }
  17.         });
  18.  
  19.     }
  20. }
  21.  
  22.  
  23. 2nd activity for reverse
  24.  
  25. public class second extends AppCompatActivity {
  26. Button back;
  27.     @Override
  28.     protected void onCreate(Bundle savedInstanceState) {
  29.         super.onCreate(savedInstanceState);
  30.         setContentView(R.layout.activity_second);
  31.  
  32.         back=(Button) findViewById(R.id.b2);
  33.       back.setOnClickListener(new View.OnClickListener() {
  34.           @Override
  35.           public void onClick(View v) {
  36.               Intent b= new Intent(second.this,MainActivity.class);
  37.               startActivity(b);
  38.               finish();
  39.           }
  40.       });
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement