jav*_*acm 6 java compatibility android kotlin aar
我有一个kotlin库FlowLayout lib as aar,
并希望在我的java代码(android)中使用它,但无法解决kotlin.Pair.
FlowLayoutManager layoutManager=new FlowLayoutManager(3, RecyclerView.HORIZONTAL, new FlowLayoutManager.Interface() {
@Override
public kotlin.Pair<Integer, Integer> getProportionalSizeForChild(int i) {
return null;
}
});
Run Code Online (Sandbox Code Playgroud)
我试过android.support.v4.util.Pair但不兼容.如何在java代码中使用kotlin lib及其对象依赖项?
vod*_*dan 12
类kotlin.Pair属于标准库org.jetbrains.kotlin:kotlin-stdlib:1.0.0,因此您必须将此库作为依赖项.
不建议Pair在公共API中使用.而不是那样,data class用2个属性创建自己的属性,并给它们一个比first和更清晰的命名second.
目的Pair是将服务器作为任何中间操作中的临时数据载体.如果您在API中使用它,则会失去清晰度.