Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

单个格子背景问题 #14

Closed
hwx-33 opened this issue Feb 2, 2018 · 4 comments
Closed

单个格子背景问题 #14

hwx-33 opened this issue Feb 2, 2018 · 4 comments

Comments

@hwx-33
Copy link

hwx-33 commented Feb 2, 2018

你好,我想获取某一列数据的最大值最小值并为其设置其背景颜色,要是最大最小值都只有一个还可以,但是一旦同时有很多最大值的时候就不好做了,设置颜色部分如下
table.getConfig().setContentBackgroundFormat(new BaseCellBackgroundFormat() {
@OverRide
public int getBackGroundColor(CellInfo cellInfo) {
if ("voltage".equals(cellInfo.column.getFieldName()) && ((cellInfo.position == maxV))) {
return ContextCompat.getColor(MainActivity.this, R.color.selectColor);
} else if ("voltage".equals(cellInfo.column.getFieldName())&& ((cellInfo.position == minV))) {
return ContextCompat.getColor(MainActivity.this, R.color.column_bg);
} else {
return TableConfig.INVALID_COLOR;
}
}
});

@huangyanbin
Copy link
Owner

这个你可以自己先遍历一遍,把最大的和最小数值都记录下来,然后设置。

@huangyanbin
Copy link
Owner

如果我在框架增加这个方法,有点画蛇添足,因为需求是不定的,判断规则也可能变化,而是还需要判断是否是基本类型(除boolean),还有包装类型。最后功能更加复杂,使用起来却没有更加好。

@hwx-33
Copy link
Author

hwx-33 commented Feb 2, 2018

最大最小值的position我记录下来了 现在就是每次有一个新的最大值和之前最大值相同的话 之前的那些最大值的position又都要重新写进去

@huangyanbin
Copy link
Owner

你可以用数组和List记录一下哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants