没有类型参数的乐趣findViewById(p0:Int):视图
我试图像这样在Kotlin上声明一个imageView:
view.findViewById<ImageView>(R.id.tabImage)).setImageResource(selector)
但我总是这个错误,
Error:(30, 27) No type arguments expected for fun findViewById(p0: Int): View!
有人可以帮助PLZ吗? 谢谢
应该是这样的
ImageView imageView = view.findViewById<ImageView>(R.id.tabImage) imageView.setImageResource(selector)
ImageView imageView = view.findViewById(R.id.tabImage) as ImageView imageView.setImageResource(selector)
尝试这个
private var aImageView : ImageView? = null aImageView = findViewById(R.id.imageview) as ImageView
- 用fillafter(true)|查看 kotlin | Android
- 在intellij 16中创建Android应用时,Gradle同步失败
- GridView只在单击项目时删除第一个项目。 基于Java>Kotlin
- JaCoCo用Kotlin和Android 3.0返回0%的覆盖率
- 在Android Kotlin应用程序中如何处理大数目?
- 如何在AndroidStudio中使用Dagger2和Kotlin在其他项目模块中实现接口库
- 升级到kotlin RC1(1.0.0-rc-1036)之后的java.lang.IncompatibleClassChangeError
- Kotlin当多个值不工作时值是一个Android视图
- 如何设置文本,焦点,在与Kotlin Android的editText错误