So i made a homepage for my app (activity_home.xml / HomeActivity.java) and added 4 buttons , each buttons takes the user to a specific activity, so far 2 are working fine, but the last two either reload the home activity or restart the app.
the 2 activities i'm talking about are named (yoga3.xml / activity_yoga3.java) and (cardio2.java /activity_cardio2.xml).
activity_home.xml :
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/buttonn3"
android:layout_width="300dp"
android:layout_height="79dp"
android:layout_below="@id/buttonn2"
android:layout_marginLeft="60dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="2dp"
android:background="@android:color/transparent"
android:fontFamily="@font/airstrike"
android:onClick="cardio2"
android:text="@string/your_string3"
android:textColor="@color/design_default_color_error"
android:textSize="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent">
</androidx.appcompat.widget.AppCompatButton>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/buttonn4"
android:layout_width="300dp"
android:layout_height="79dp"
android:layout_below="@id/buttonn3"
android:layout_marginLeft="60dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="2dp"
android:background="@android:color/transparent"
android:fontFamily="@font/airstrike"
android:onClick="yoga3"
android:text="@string/your_string4"
android:textColor="@android:color/holo_green_light"
android:textSize="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent">
</androidx.appcompat.widget.AppCompatButton>
HomeActivity.java :
Button buttonn = (Button) findViewById(R.id.buttonn1);
Button buttonn2 = (Button) findViewById(R.id.buttonn2);
Button buttonn3 = (Button) findViewById(R.id.buttonn3);
Button buttonn4 = (Button) findViewById(R.id.buttonn4);
buttonn.setOnClickListener(v -> {
Intent intent = new Intent(this,WaterActivity.class);
startActivity(intent);
});
buttonn2.setOnClickListener(v -> {
Intent intent = new Intent(this,Bodybuilding.class);
startActivity(intent);
});
buttonn3.setOnClickListener(v -> {
Intent intent = new Intent(this,cardio2.class);
startActivity(intent);
});
buttonn4.setOnClickListener(v -> {
Intent intent = new Intent(this,yoga3.class);
startActivity(intent);
});
i changed the buttons to another activity and it worked, but when i change it back to yoga3 and cardio2 it doesn't work