[英]Type mismatch: inferred type is String but Int was expected , Kotlin
What is the problem?问题是什么? The IDE itself tells you, an Int was expected but you are passing a String. IDE 本身告诉你,一个 Int 是预期的,但你传递的是一个字符串。
To get values from resources, for example, strings, themes, etc... you need to pass an Int or id of the resource, which is obtained by doing从资源中获取值,例如字符串、主题等...需要传入资源的一个Int或者id,通过doing获取
R.id.your_resource
So looking at your code:所以看看你的代码:
val InterstitialId = dataSnapshot.child("interstitial_id").value.toString()
This line will return a string when you call the .toString
method, 2 lines below you are passing this variable to a .getString
and according to the documentation getString()
expects an Int not a String.当您调用.toString
方法时,此行将返回一个字符串,下面的 2 行将此变量传递给.getString
并且根据文档getString()
需要一个 Int 而不是 String。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.