move to another activity when button pressed android studio code example
Example 1: how to move from one activity to another in android studio on button click
public void next(View view) {
Intent intent = new Intent(this,Activity2.class);
startActivity(intent);
}
Example 2: how to move from one activity to another in android studio on button click
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main4);
button = (Button)findViewById(R.id.button7);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openInsideActivity4();
}
});
}
public void openInsideActivity4()
{
Intent intent = new Intent(this,InsideActivity4.class);
startActivity(intent);
}