错误写法
if(calendar.AM_PM==calendar.AM){
daysection= AppConst.MORNING
section.setCurrentItem(0)
}else{
daysection=AppConst.AFTERNOON
section.setCurrentItem(1)
}
正确写法
int r = calendar.get(Calendar.AM_PM)
if(r==Calendar.AM){
daysection= AppConst.MORNING
section.setCurrentItem(0)
}else{
daysection=AppConst.AFTERNOON
section.setCurrentItem(1)
}
或者这样也可以
Calendar now = Calendar.getInstance();
if (now.get(Calendar.AM_PM) == 0) {
startTimeDaySectionText.setText("上午");
daySectionManager = true;
} else {
startTimeDaySectionText.setText("下午");
daySectionManager = false;
}