findViewById ClassCastExcpetion
我使用kotlin-extension插件来查找视图。
但现在我得到一个例外
setSupportActionBar(mainActivity_toolbar)
它一直工作到现在,但现在它给了一个
ClassCastException: android.widget.FrameLayout cannot be cast to android.support.v7.widget.Toolbar
我做的最后一件事就是给我的fab添加一个id并设置一个OnClickListener
。
但在我的layout.xml中:
android.support.v7.widget.Toolbar
的ID为"@+id/mainActivity_toolbar"
, FrameLayout
的ID为"@+id/mainActivity_framelayout"
。
我首先以为在kotlin-extension插件中有一个bug,但是使用findViewById
也是行不通的。
谢谢
重新启动IntelliJ解决了我的问题。
没有想到,只重建了我的项目,并没有帮助。
由于这个职位 ,我认为这可能是我的问题,因为重建dosn't帮助,我重新启动IntelliJ,它的工作。
- Kotlin转换不再适用于Android Studio 3.0
- Kotlin Android扩展缓存合成属性还是每次调用findViewById()?
- 房间:使用@Transaction时收到错误
- Android构建失败,kotlin-reflect和proguard
- Android Kotlin计算速度(时间)
- Rxjava与kotlin
- java.lang.NoClassDefFoundError:com.example.api.retrofit.AuthenticationInterceptor $ intercept $ 1
- 如何在Kotlin中使用KeyEvent
- 詹金斯:Android项目未能建立(生成数据绑定/匕首类失败)