I am a beginner in android, and currently I am working on an app which requires usage of a else if statement. Below is the code snippet of the same:
submit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if ((CCValue.equals("3") && MVValue.equals("3.5")) || (CCValue.equals("3") && MVValue.equals("4")) || (CCValue.equals("3") && MVValue.equals("5")) ||
(CCValue.equals("4") && MVValue.equals("4.5")) || (CCValue.equals("4") && MVValue.equals("5")) || (CCValue.equals("5") && MVValue.equals("5"))) {
thresholdValue = 1;
} else {
thresholdValue = 0;
}
threshold.setText(thresholdValue);
}
});
Submit is the name of the button on which the user will click, and the compiler will go in the "if" statement. CCValue and MVValue are string variables, which I am saving from two spinners selected by the user. "thresholdValue" is an integer variable which will get value according to the if statement. Finally "threshold" is an EditText component.
Now I am trying to compare the values stored withing the string variables through the "if" condition. But every time whenever I am clicking on the submit button the app is getting crashed. What changes should I make to make this code run successfully?
Aucun commentaire:
Enregistrer un commentaire