Android 如何解决对重载定义的不明确引用

Android 如何解决对重载定义的不明确引用,android,scala,types,casting,type-conversion,Android,Scala,Types,Casting,Type Conversion,在我使用的方法中,有重载方法: put(字符串键,整数值) put(字符串键,长值) put(字符串键,双值) put(字符串键、浮点值) 我试图将String和Int值放在那里,但我得到以下错误: Error:(41) ambiguous reference to overloaded definition, both method put in class ContentValues of type (x$1: String, x$2: Double)Unit and method p

在我使用的方法中,有重载方法:

  • put(字符串键,整数值)
  • put(字符串键,长值)
  • put(字符串键,双值)
  • put(字符串键、浮点值)
我试图将
String
Int
值放在那里,但我得到以下错误:

Error:(41) ambiguous reference to overloaded definition,
both method put in class ContentValues of type (x$1: String, x$2: Double)Unit
and  method put in class ContentValues of type (x$1: String, x$2: Float)Unit
match argument types (String,Long)

在这种情况下我能做什么?

您正在尝试放置一个
Int
,但是没有重载方法可以接受该值,因此编译器尝试使用隐式转换。我的猜测是,它看到您可以隐式地将其转换为
双精度
浮点
,但它不知道使用哪个。因此,让我们帮助解决这个问题:

val myJavaInteger: java.lang.Integer = myScalaInt
现在使用myjavainteger调用put,不会有任何混淆,因为有一个重载put方法接受
java.lang.Integer