这是我的代码,当我尝试运行它并选择时 头痛,出汗,虚弱,寒战,骨痛和关节疼痛病毒感染。课程活动开始而不是chickengunia.class。这有什么问题?
@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);
}
}
});
}
}
这是我的类文件,它只执行第一个if语句,因为我选择的按钮位于该语句中。
答案 0 :(得分:0)
<强>原因:强>
问题似乎是您ViralFever
语句之前的Chickengunia
检查。会发生什么情况,它首先检查ViralFever
的症状,其症状与Chickengunia
的症状子集相同。
<强>解决方案:强>
您可以做的是交换ViralFever
和Chickengunia
的代码。
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()) {
Intent Intents = new Intent(Questionnaire.this, ViralFever.class);
startActivity(Intents);
}
依旧......
答案 1 :(得分:0)
if(isHeadeck&& isPain&&isSweat&&isChills){
if(jointPin&&isBonepain)
Intent Intents = new Intent(Questionnaire.this, Chickengunia.class);
startActivity(Intents);
else
Intent Intents = new Intent(Questionnaire.this, ViralFever.class);
startActivity(Intents);
}