如何使用 @FragmentArg
来自 AndroidAnnotations
在 Kotlin
内分段?
@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
(公共(public)),但它不起作用。有任何想法吗?这甚至可能吗?我正在使用 Android Annotations 4.3.1 和 kotlin 1.1.2-5
最佳答案
好的,@JvmField
是你的 friend 。 (further information)
Instructs the Kotlin compiler not to generate getters/setters for this property and expose it as a field.
所以
@FragmentArg
应该是这样的@JvmField
@FragmentArg("debugIndex")
var debugIndex:Int = 0
关于android-fragments - 如何在 Kotlin 中使用 AndroidAnnotation @FragmentArg?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44718209/