I have been trying to learn android studio and I wanted to make a button that transitioned from one screen to the other Here is my code for it:
public class MainActivity extends AppCompatActivity {
private AppCompatActivity AppCompatActivity;
private TextView openingText;
private Button alarmButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
openingText = findViewById(R.id.openingText);
nextButton();
}
//this function causing issues (maybe because more than just button on screen)
private void nextButton(){
Button calculatorButton = (Button) findViewById(R.id.backButton);
calculatorButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view){
startActivity(new Intent(MainActivity.this, Calculators.class));
}
});
}
}
(I only made the calculator screen for now, only that button should work) Followed this tutorial: https://www.youtube.com/watch?v=6RtF_mbHcEc&ab_channel=AdobeinaMinute But every time I try to run the app, it just crashes. Without the button function, it works tho. Is there something I'm missing?