Android: java.lang.ClassCastException: android.widget.imageView cannot be cast to android.widget.tex

时间:2023-01-20 23:27:19

遇到问题:

Android: java.lang.ClassCastException: android.widget.imageView cannot be cast to android.widget.textView


原因:

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.

解决方案:

  1. Clean 你的项目.
  2. 修改一个xml文件,然后保存
  3. 删除 R 文件. (build project 之后会自动生成).

自:http://*.com/questions/11191040/android-java-lang-classcastexception-android-widget-imageview-cannot-be-cast-t