搜尋此網誌

2015年1月15日 星期四

【Android】java.lang.ClassCastException: android.widget.... cannot be cast to android.widget....

Solve method:

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.

ref:

沒有留言: