调用Emun class 老是报错误 “ 'name' hides member of supertype 'Enum' and needs 'override' modifier ”
代码如下:
enum class ApprovalTypeCode(
val name: String,
val code: String,
val resId: Int,
val brief: String
)
APPROVAL_COMMON("通用审批", "common", R.drawable.ic_approval_create_list_common_approval, ""), APPROVAL_ADD_APPROVAL("添加审批", "add_approval", R.drawable.ic_approval_create_more, ""); // fun gotoApprovalActivity(activity: Activity) { // when (this) { // APPROVAL_RECEIVE_FILE -> {} // APPROVAL_SEND_FILE -> {} // } // } companion object { fun getEnumByCode(code: String?): ApprovalTypeCode { for (e in values()) { if (e.code.equals(code, ignoreCase = true)) { return e } } return APPROVAL_RECEIVE_FILE } } }
原来确实重名了,只要把上面红色的部分(val name: String), 改成 val title: String 即可。
纯记录埋坑