gpt4 book ai didi

android - 在 kotlin 中调用父类中的内部类不起作用

转载 作者:行者123 更新时间:2023-11-30 00:01:40 24 4
gpt4 key购买 nike

当我遇到这种奇怪的行为时,我正在将一个 java 项目转换为 kotlin。

在 Java 中:

new ImageSwitcher.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

工作正常。

但在 kotlin 中它给了我编译错误:

ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)


LayoutParams is an inner class in `FrameLayout` which is the parent of `ImageSwitcher`

enter image description here

我知道我可以使用 FrameLayout.LayoutParams 但为什么原始代码不起作用?

最佳答案

kotlin 中没有静态继承,我想这是正确的做法,因为静态继承可能会导致模棱两可的错误。

关于android - 在 kotlin 中调用父类中的内部类不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49818313/

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