gpt4 book ai didi

android-fragments - 如何在 Kotlin 中使用 AndroidAnnotation @FragmentArg?

转载 作者:行者123 更新时间:2023-12-02 13:06:39 26 4
gpt4 key购买 nike

如何使用 @FragmentArg来自 AndroidAnnotationsKotlin 内分段?

@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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com