如何在Kotlin中使用AndroidAnnotation @FragmentArg?
我如何使用Kotlin
片段中的@FragmentArg
的AndroidAnnotations
?
@EFragment(R.layout.debug_empty_fragment) open class EmptyFragment : Fragment(){ @FragmentArg("debugIndex") var debugIndex:Int = 0 }
这给我下面的gradle错误:
error: org.androidannotations.annotations.FragmentArg cannot be used on a private element
我试图使debugIndex open
(公共) ,但它不工作。 有任何想法吗? 这甚至有可能吗?
我使用Android Annotations 4.3.1和kotlin 1.1.2-5
好的, @JvmField
是你的朋友。 ( 更多信息 )
指示Kotlin编译器不要为此属性生成getter / setter,并将其作为字段公开。
所以@FragmentArg
应该像这样
@JvmField @FragmentArg("debugIndex") var debugIndex:Int = 0