I'm using android studio and need help with adding a button that can take you to the next page of the app.
Asked
Active
Viewed 2,038 times
2 Answers
0
you have to use Intents to go to another page in android studio
Add to your button an onClick function:
android:onClick="startSecondActivity"
and then you have to add the function which should look like this:
public void startSecondActivity(View view) {
Intent intent = new intent (this, secondActivity.class);
startActivity(Intent);
}

bosman2
- 39
- 1
- 2
- 7
0
1.Add onClick event to Button.
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="goNextPage" />
2.Within the Activity that hosts this layout, the following method handles the click event:
/** Called when the user touches the button */
public void goNextPage(View view) {
startActivity(new Intent(CurrentActivity.this, NextActivity.class));
}
If you want to go Fragment, I will update my answer.

CleanCoder
- 332
- 3
- 14