-1

I have 2 actvities with a xml each but I don't know how to switch to the second page with a button.

Can someone send me the code for the MainActivitie.java please (for a button)

I currently use the findView and onClick

Nobler
  • 1
  • Does this answer your question? [How to start new activity on button click](https://stackoverflow.com/questions/4186021/how-to-start-new-activity-on-button-click) – Hamed Nov 04 '22 at 10:40

1 Answers1

1

In your MainActivity use this code:

  Intent intent = new Intent(MainActivity.this, Second.java);
  startActivity(intent);

Please read about "Intents", I have added some links that will clear your concepts. Previously asked question Intent Types

Umair Qayyum
  • 54
  • 1
  • 6