【发布时间】:2020-06-04 17:21:48
【问题描述】:
在 kotlin 我比较新鲜,请告诉我
//In onBindViewHolder method :
val context = holder.itemView.context
//Here I want to change background colour so please tell me or comment
if (position % 2 == 0) {
holder.binding.root.setBackgroundColor(ContextCompat.getColor(context,R.color.colorAccent))
} else {
holder.binding.root.setBackgroundColor(ContextCompat.getColor(context,R.color.colorPrimary))
}
提前致谢!
【问题讨论】:
-
所有发布的都是程序描述。但是,我们需要您ask a question。我们无法确定您想从我们这里得到什么。请edit您的帖子包含一个我们可以回答的有效问题。提醒:请确保您知道what is on-topic here,请我们为您编写程序,建议是题外话。
标签: java android kotlin kotlin-coroutines kotlin-android-extensions