直接上代码
//设置隔行显示不同颜色
ICellBackgroundFormat<CellInfo> backgroundFormat = new BaseCellBackgroundFormat<CellInfo>() {
@Override
public int getBackGroundColor(CellInfo cellInfo) {
if(cellInfo.row %2 == 0) {
return ContextCompat.getColor(getContext(), R.color.report_item);
}
return TableConfig.INVALID_COLOR;
}
};
//设置每行 标题字体和背景
ICellBackgroundFormat<Integer> backgroundFormat2 = new BaseCellBackgroundFormat<Integer>() {
@Override
public int getBackGroundColor(Integer position) {
if(position%2 == 0){
return ContextCompat.getColor(getContext(),R.color.report_item_title);
}
return TableConfig.INVALID_COLOR;
}
@Override
public int getTextColor(Integer position) {
if(position%2 == 0) {
return ContextCompat.getColor(getContext(), R.color.white);
}
return TableConfig.INVALID_COLOR;
}
};
smartTable.getConfig().setContentCellBackgroundFormat(backgroundFormat)
.setYSequenceCellBgFormat(backgroundFormat2);