我正在尝试Parcelize
数据类.它包含一个参数:
var tokenType: Any? = null
Run Code Online (Sandbox Code Playgroud)
对于这个变量编译器在编译时抱怨:
Type is not directoly supported by Parcelize.
Annotate the parater with @RawValue if you want it to be serialized via
writeValue()
Run Code Online (Sandbox Code Playgroud)
虽然错误是自我解释的,但当我添加@RawValue时:
@RawValue var tokenType: Any? = null
Run Code Online (Sandbox Code Playgroud)
它给出了一个错误:
This annotation is not applicable to target value parameter
Run Code Online (Sandbox Code Playgroud)
有关如何处理此问题的任何提示?
Tar*_*run 23
我从Kotlang
社区得到了这个问题的答案.答案是您无法对变量本身进行注释,但您必须对其类型进行注释.
因此,通过以下方式进行注释可以消除错误:
var tokenType: @RawValue Any? = null
Run Code Online (Sandbox Code Playgroud)
虽然不要忘记手动为此属性编写serilizer/deserializer,因为它不会自动完成.
希望能帮助到你.
归档时间: |
|
查看次数: |
3400 次 |
最近记录: |