相关疑难解决方法(0)

为什么从Android的性能提示中删除了"避免只需要Ints的枚举"?

从官方开发者文档中删除了"避免只需要Ints的枚举"部分.(请参阅为什么Android不使用更多枚举?对于旧版内容)

为什么?是否有Android VM的更改使得提示过时了?

enums android

171
推荐指数
6
解决办法
3万
查看次数

Kotlin Annotation IntDef

我有这个代码示例:

class MeasureTextView: TextView {
    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)

    companion object{
        val UNIT_NONE = -1
        val UNIT_KG = 1
        val UNIT_LB = 0            
    }

    fun setMeasureText(number: Float, unitType: Int){

        val suffix = when(unitType){
            UNIT_NONE -> {
                EMPTY_STRING
            }
            UNIT_KG -> {
                KG_SUFIX
            }
            UNIT_LB -> {
                LB_SUFIX
            }
            else -> …
Run Code Online (Sandbox Code Playgroud)

annotations kotlin

26
推荐指数
3
解决办法
2万
查看次数

标签 统计

android ×1

annotations ×1

enums ×1

kotlin ×1