This question already has an answer here:
- How do I compare strings in Java? 23 answers
My application is working fine until I add if statement in the new intent the application suddenly closing. I would like to go to the new intent base on what radio button is selected.
@Override
public void onClick(View view) {
int RadioId = radioGroupB.getCheckedRadioButtonId();
radioButton = findViewById(RadioId);
if (radioButton.getText()=="Circle"){
Intent intenta=new Intent(getApplicationContext(),SecAct.class);
intenta.putExtra ( "1", editText.getText().toString());
intenta.putExtra("2", editText2.getText().toString());
startActivity(intenta);
} if (radioButton.getText()=="Square"){
Intent intent=new Intent(getApplicationContext(),square.class);
intent.putExtra ( "1", editText.getText().toString());
intent.putExtra("2", editText2.getText().toString());
startActivity(intent);
}
}
Here's what it looks like when I add if statement.
Aucun commentaire:
Enregistrer un commentaire