我做了一个申请,我把DAY_OF_MONTH条件放在(如果)之后像这样
if (cal.get(Calendar.DAY_OF_MONTH) == 9) {
Intent intent1 = new Intent(MainActivity.this, TextActivity.class);
intent1.putExtra("key", getResources().getString(R.string.s_monday_txt));
startActivity(intent1);
finish();
} else if (cal.get(Calendar.DAY_OF_MONTH) == 10) {
Intent intent2 = new Intent(MainActivity.this, TextActivity.class);
intent2.putExtra("key", getResources().getString(R.string.s_tuesday_txt));
startActivity(intent2);
finish();
}
在另一个地方,我像这样在(如果)之后放置了 MONTH 条件
if (cal.get(Calendar.MONTH) == Calendar.SEPTEMBER) {
Intent intent1 = new Intent(MainActivity.this, TextActivity.class);
intent1.putExtra("key", getResources().getString(R.string.s_september_txt));
startActivity(intent1);
finish();
} else if (cal.get(Calendar.MONTH) == Calendar.AUGUST) {
Intent intent2 = new Intent(MainActivity.this, TextActivity.class);
intent2.putExtra("key", getResources().getString(R.string.s_august_txt));
startActivity(intent2);
finish();
}
这对我来说很好,但问题是如何像这样同时检查这两个条件
if (cal.get(Calendar.MONTH) == Calendar.SEPTEMBER) + (cal.get(Calendar.DAY_OF_MONTH) == 9) {
Intent intent1 = new Intent(MainActivity.this, TextActivity.class);
intent1.putExtra("key", getResources().getString(R.string.s_september_txt));
startActivity(intent1);
finish();
} else if (cal.get(Calendar.MONTH) == Calendar.AUGUST) + (cal.get(Calendar.DAY_OF_MONTH) == 10) {
Intent intent2 = new Intent(MainActivity.this, TextActivity.class);
intent2.putExtra("key", getResources().getString(R.string.s_august_txt));
startActivity(intent2);
finish();
}
我试过 (+) , (and), (||), (,) 所有这些都没有任何帮助???