我有这个 if else 语句的代码
@Override
public void onClick(View arg0) {
int aInt = Integer.parseInt(textView1.getText().toString());
if(aInt <= 0) {
Toast.makeText(getApplicationContext(), "Wrong",
Toast.LENGTH_SHORT).show();
} else{
int a=Integer.parseInt(textView1.getText().toString());
int b=a-2;
String s1 = String.valueOf(b);
textView1.setText(s1);
Toast.makeText(getApplicationContext(), "Wrong",
Toast.LENGTH_SHORT).show();
int c =Integer.parseInt(textView5.getText().toString());
int d = c-1;
String s2 = String.valueOf(d);
textView5.setText(s2);
} if(textView5 != null) {
int dInt = Integer.parseInt(textView5.getText().toString());
if(dInt <= 0);
Toast.makeText(getApplicationContext(), "Game Over",
Toast.LENGTH_SHORT).show();
Intent intent = new Intent();
intent.setClass(MainActivity.this, Fifth.class);
startActivity(intent);
SavePreferences("MEM1", textView1.getText().toString());
}
}
};
在这部分代码上,如果 textView5 的值为 0,我想启动意图,但即使 textView5 的值还不是 0,它仍然会进入新的意图,我不知道我的代码的哪一部分是错误的:
} if(textView5 != null) {
int dInt = Integer.parseInt(textView5.getText().toString());
if(dInt <= 0);
Toast.makeText(getApplicationContext(), "Game Over",
Toast.LENGTH_SHORT).show();
Intent intent = new Intent();
intent.setClass(MainActivity.this, Fifth.class);
startActivity(intent);
}