有时在修改xml文件时,全报这种错误,这个应该是缓存没得到及时更新导致的,可以通过以下方法解决:
Eclipse tends to mess up your resources every now and then. This leads to some odd behavior such as strings and images being swapped all over your app, and more commonly classCastException(s), which happen when Eclipse switches your Views‘ ids around.
A few solutions to that problem:
Clean your project.
Modify an xml layout file and save.
Delete your R file. (Don‘t worry it will be automatically generated again).
Basically anything that makes your project rebuild and re-generate the R file.
URL:http://stackoverflow.com/questions/11191040/android-java-lang-classcastexception-android-widget-imageview-cannot-be-cast-t
时间: 2024-10-12 12:37:40