【发布时间】:2019-04-05 04:27:14
【问题描述】:
我正在尝试根据适配器的位置和状态更改时间线的颜色。但它不工作。我正在使用如下条件动态尝试:
private fun setLineColor(holder: TimeLineViewHolder, position: Int, status: OrderStatus) {
when (position) {
0 -> {
when (status) {
OrderStatus.COMPLETED -> holder.timeline.setEndLineColor(R.color.colorAccent, 1)
OrderStatus.INACTIVE -> holder.timeline.setEndLineColor(R.color.grey_color, 1)
OrderStatus.ACTIVE -> holder.timeline.setEndLineColor(R.color.grey_color, 1)
}
}
mFeedList.size - 1 -> {
when (status) {
OrderStatus.COMPLETED -> holder.timeline.setStartLineColor(R.color.colorAccent, 2)
OrderStatus.INACTIVE -> holder.timeline.setStartLineColor(R.color.grey_color, 2)
OrderStatus.ACTIVE -> holder.timeline.setStartLineColor(R.color.grey_color, 2)
}
}
else -> {
when (status) {
OrderStatus.COMPLETED -> {
holder.timeline.setStartLineColor(R.color.colorAccent, 0)
holder.timeline.setEndLineColor(R.color.colorAccent, 0)
}
OrderStatus.INACTIVE -> {
holder.timeline.setStartLineColor(R.color.grey_color, 0)
holder.timeline.setEndLineColor(R.color.grey_color, 0)
}
OrderStatus.ACTIVE -> {
holder.timeline.setStartLineColor(R.color.colorAccent, 0)
holder.timeline.setEndLineColor(R.color.grey_color, 0)
}
}
}
}
}
但颜色仅显示为灰色。也参考#21
我在 github 中发现了很多关于此的查询,但它指向另一个链接,但这也不起作用。 this is a link
我唯一需要做的就是直到当前位置我需要强调颜色,然后是禁用颜色。有没有人对此有解决方案?
【问题讨论】:
-
您用于时间轴视图的库是什么?