【发布时间】:2019-05-15 23:13:47
【问题描述】:
有没有办法用资源注释来注释整数列表,以便当我错误地使用方法的整数返回值时,lint 会向我显示错误?
示例(setTextColor() 只需要@ColorInt):
fun useColor() {
val textView = TextView(null)
textView.setTextColor(getColor()) // This correctly shows an error
textView.setTextColor(getColorList()[0]) // Can I make this show an error too?
}
@ColorRes
fun getColor() : Int {
return R.color.black
}
@ColorRes // any way to specify this differently?
fun getColorList() : List<Int>{
return arrayListOf(R.color.black)
}
【问题讨论】:
标签: android kotlin annotations lint