类似Toast设置显示时常,只能选择限定的值:LENGTH_SHORT或 LENGTH_LONG。
public static Toast makeText(Context context, CharSequence text, @Duration int duration) {
return makeText(context, null, text, duration);
}
自定义注解:
/**
* 添加物品时,区分类型
*/
@StringDef(value = [TYPE.VEHICLE_INSPECT, TYPE.PERSON_INSPECT])
@Retention(AnnotationRetention.SOURCE)
annotation class TYPE {
companion object {
const val VEHICLE_INSPECT: String = "2"//车辆核查
const val PERSON_INSPECT: String = "3"//人员核查
}
}
调用时:
fun start(mActivity: Activity, recordId: Int, personInfoList: MutableList<PersonInfo>?, @TYPE type: String) {}