-6

I am new in android how to go next activity in button click.

  button.setoncliklistener(new OnClickListener(){
   public void onclick (View v){


    }
     });
Nishanthi Grashia
  • 9,787
  • 5
  • 42
  • 57

3 Answers3

0

Assume you have ActivityA and ActivityB and you want to move from ActivityA to ActivityB, then

In ActivityA.class, use:

  button.setoncliklistener(new OnClickListener(){
   public void onclick (View v){

    Intent intent = new Intent ( getApplicationContext(), ActivityB.class);
    startActivity(intent);  
    finish();   
     }
 });

Tutorials:

Nishanthi Grashia
  • 9,787
  • 5
  • 42
  • 57
0
button.setoncliklistener(new OnClickListener(){
   public void onclick (View v){
          Intent intent(CurrentActivity.this, NextActivity.class);
          startActivity(intent);
          finish();//If want to finish previous activity, if not then dont write this line.

    }
     });
Pratik Dasa
  • 7,389
  • 4
  • 29
  • 44
0
button.setoncliklistener(new OnClickListener(){
   public void onclick (View v){

    Intent intent = new Intent ( this, next.class);
    startActivity(intent);  
    finish();   
     }
 });
Mani
  • 902
  • 10
  • 14