Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1st activity of java
- public class MainActivity extends AppCompatActivity {
- Button bnext;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- bnext =(Button) findViewById(R.id.b1);
- bnext.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent a =new Intent(MainActivity.this,second.class);
- startActivity(a);
- finish();
- }
- });
- }
- }
- 2nd activity for reverse
- public class second extends AppCompatActivity {
- Button back;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_second);
- back=(Button) findViewById(R.id.b2);
- back.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent b= new Intent(second.this,MainActivity.class);
- startActivity(b);
- finish();
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement