Hello. I am new to programming here. I am currently trying to make an
application for displaying stats for the heroes in Overwatch. I currently
have activities for Orisa, D.va, and Reinhardt at the moment. Currently, if
I want to open the activity for Reinhardt, I have to open the activity for
Orisa, then D.va, before I can get to Reinhardt. This is what I have so
far. Any help would be much appreciated. Thank you.
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
private Button button;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Open the page for Orisa
button = findViewById(R.id.btnOrisa);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
openactivity_orisa();
}
});
}
public void openactivity_orisa() {
Intent intent = new Intent(this, orisa.class);
startActivity(intent);
//Open the page for D.va
button = findViewById(R.id.btnDva);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
openactivity_dva();
}
});
}
public void openactivity_dva() {
Intent intent = new Intent(this, Dva.class);
startActivity(intent);
//Open the page for Reinhardt
button = findViewById(R.id.btnReinhardt);
button.setOnClickListener(new View.OnClickListener() {
public void onClick ( View v ) {
openactivity_rein1();
}
});
}
public void openactivity_rein1() {
Intent intent = new Intent(this, Rein1.class);
startActivity(intent);
}}
Enter code here...
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/87aa16ad-4360-4209-a97c-ab543466d653%40googlegroups.com.