我正在尝试将 Java 项目转换为 Kotlin。我得到一个非常奇怪的编译时错误函数直到 是一个“ Unresolved reference ”,这个函数怎么来的直到 不承认?
fun renderChildrenToRight(canvas: Canvas, startIndex: Int, stopIndex: Int) {
val itemRight = nodePosition!!.x + nodeRectLimits.right
val itemExternalPaddingWidth = getRenderAttribute(AttributeExternalPaddingWidth, AttributeDefaultExternalPadding)
val itemTop = nodePosition!!.y + nodeRectLimits.top
val itemExternalPaddingHeight = getRenderAttribute(AttributeExternalPaddingHeight, AttributeDefaultExternalPadding)
val childItemsSize = getChildItemsSize(startIndex, stopIndex)
var nextItemTop = itemTop + childItemsSize / 2
val x = itemRight + itemExternalPaddingWidth
for (i in startIndex until stopIndex) {
val currentNode = _children[i]
val bulletDesiredHeight = currentNode.desiredHeightWithChildren
val y = nextItemTop - bulletDesiredHeight / 2
currentNode.setNodePosition(x, y)
currentNode.renderWithChildren(canvas, BulletRenderStyle.ToTheRight)
nextItemTop -= bulletDesiredHeight + itemExternalPaddingHeight
}
}
这是我的旧 Java 方法:
public void renderChildrenToRight(Canvas canvas, int startIndex, int stopIndex) {
int itemRight = getNodePosition().x + getNodeRectLimits().right;
int itemExternalPaddingWidth = getRenderAttribute(AttributeExternalPaddingWidth, AttributeDefaultExternalPadding);
int itemTop = getNodePosition().y + getNodeRectLimits().top;
int itemExternalPaddingHeight = getRenderAttribute(AttributeExternalPaddingHeight, AttributeDefaultExternalPadding);
int childItemsSize = getChildItemsSize(startIndex, stopIndex);
int nextItemTop = itemTop + childItemsSize / 2;
int x = itemRight + itemExternalPaddingWidth;
for (int i = startIndex; i < stopIndex; i++) {
Node currentNode = _children.get(i);
int bulletDesiredHeight = currentNode.getDesiredHeightWithChildren();
int y = nextItemTop - bulletDesiredHeight / 2;
currentNode.setNodePosition(x, y);
currentNode.renderWithChildren(canvas, BulletRenderStyle.ToTheRight);
nextItemTop -= bulletDesiredHeight + itemExternalPaddingHeight;
}
最佳答案
您的 Intellij IDEA 插件和您在项目中使用的 Kotlin 运行时/编译器需要匹配。您的 android studio 必须升级为支持 kotlin。检查所有这些并重新启动您的 android studio。
关于android - Kotlin 中 Unresolved 函数 'until' 引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53992611/