Android Studio open new screen code example

Example 1: how to move from one activity to another in android studio on button click

// also use set onclick listener
 public void next(View view) {
        Intent intent = new Intent(this,Activity2.class);
        startActivity(intent);
   }

Example 2: go to activity android

//going to another activity while ending the 
//previous one so that users cannot go back
btListe = (ImageButton)findViewById(R.id.Button_Liste);
    btListe.setOnClickListener(new OnClickListener()
    {    public void onClick(View v)
        {
            intent = new Intent(main.this, ListViewImage.class);
            startActivity(intent);
            finish();
        }
    });