Kotlin Annotation IntDef

前端 未结 6 2000
不知归路
不知归路 2020-12-03 09:53

I have this code sample:

class MeasureTextView: TextView {
    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: Attr         


        
6条回答
  •  庸人自扰
    2020-12-03 10:21

    Try it:

    companion object {
        const val VALUE_1: Int = 1
        const val VALUE_2: Int = 2
        const val VALUE_3: Int = 3
    }
    
    @IntDef(value = [VALUE_1, VALUE_2, VALUE_3])
    @Retention(AnnotationRetention.SOURCE)
    annotation class TestClassName
    

提交回复
热议问题