This is my code and when I try to run it and when I select headache, sweating, weakness, chills, bone pain and joint pain viralfever.class activity gets started instead of chickengunia.class. What is the problem here?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.questionnaire);
final Button go = (Button) findViewById(R.id.submit);
go.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (headache.isChecked() && sweating.isChecked() && weakness.isChecked() && chills.isChecked()) {
Intent Intents = new Intent(Questionnaire.this, ViralFever.class);
startActivity(Intents);
}
else if (headache.isChecked() && bonepain.isChecked() && weakness.isChecked() && rashes.isChecked()) {
Intent Intents = new Intent(Questionnaire.this, Dengue.class);`enter code here`
startActivity(Intents);
}
else if (headache.isChecked() && sweating.isChecked() && skinyellow.isChecked() && palestools.isChecked() && abdoman.isChecked()) {
Intent Intents = new Intent(Questionnaire.this, Jaundice.class);
startActivity(Intents);
}
else if (diarrhea.isChecked() && sweating.isChecked() && nausea.isChecked() && dehydration.isChecked()) {
Intent Intents = new Intent(Questionnaire.this, Cholera.class);
startActivity(Intents);
}
else if (headache.isChecked() && sweating.isChecked() && weakness.isChecked() && shiver.isChecked()&& abdoman.isChecked()) {
Intent Intents = new Intent(Questionnaire.this, Malaria.class);
startActivity(Intents);
}
else if (headache.isChecked() && sweating.isChecked() && weakness.isChecked() && chills.isChecked() && bonepain.isChecked() && jointpain.isChecked()) {
Intent Intents = new Intent(Questionnaire.this, Chickengunia.class);
startActivity(Intents);
}
else if (headache.isChecked() && sweating.isChecked() && weakness.isChecked() && chills.isChecked()&& diarrhea.isChecked()&& nausea.isChecked()&& sorethroat.isChecked()&& cough.isChecked()&& runningnose.isChecked()) {
Intent Intents = new Intent(Questionnaire.this, Swineflu.class);
startActivity(Intents);
}
else if (headache.isChecked() && sweating.isChecked() && weakness.isChecked() && chills.isChecked()&& rashes.isChecked()) {
Intent Intents = new Intent(Questionnaire.this, Typhoid.class);
startActivity(Intents);
}
else
{
Intent Intents = new Intent(Questionnaire.this, Checkup.class);
startActivity(Intents);
}
}
});
}
}
This is my class file and it executes only the first if statement because the buttons I selected are in that statement.
Aucun commentaire:
Enregistrer un commentaire