我有一个自定义的ListAdapter来显示一系列数字。在 getView() 方法中,我尝试根据两个数字之间的差异设置 TextView 的背景颜色:
if (Double.compare(homeDT, homeBF) > 0) {
homeDiff.setBackgroundResource(color.holo_blue_light);
}
如果 homeBF> homeDT,这应该将 TextView 背景设置为浅蓝色,只有有时当 homeBF
知道为什么会这样吗?
试试这个
if (HomeDT > HomeBF){
// What you want to do if HomeDT is greater than HomeBF
}
else {
// What you want to do if HomeDT is not greater than HomeBF
}