-6

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

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


    }
     });
ngrashia
  • 9,869
  • 5
  • 43
  • 58

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:

ngrashia
  • 9,869
  • 5
  • 43
  • 58
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,439
  • 4
  • 30
  • 44
0
button.setoncliklistener(new OnClickListener(){
   public void onclick (View v){

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