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.

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.


Just clean up your project and everything will be fine.