[英]java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditView
I get the error in the title when i run my application, I have checked the forums but all my Edit, text views are closed. 运行应用程序时出现标题错误,我已经检查了论坛,但是所有“编辑”,“文本”视图均已关闭。 I dont really understand what the problem is, everything looks fine to me. 我真的不明白问题是什么,对我来说一切都很好。
<EditText
android:id="@+id/fairgroundName"/>
<EditText
android:id="@+id/rideName"/>
ride =(EditText)findViewById(R.id.rideName);
fairground =(EditText)findViewById(R.id.fairgroundName);
But I don't get what the problem is. 但是我不明白问题是什么。 Can anyone help please 任何人都可以帮忙吗
Your code looks fine to me too. 您的代码对我来说也很好。 Looks like the code for your EditText was not generated properly in R.java
. 看起来您的EditText的代码未在R.java
正确生成。
Clean the project. 清理项目。 Hopefully, it would remove the error. 希望它将消除该错误。
Project -> Clean 项目->清洁
Don't forget to uninstall the application from the phone before you try running it again. 在再次尝试运行该应用程序之前,请不要忘记从手机上卸载该应用程序。
Do you change The order of your views in layout file? 您是否更改布局文件中视图的顺序? Sometimes doing it cause this error. 有时这样做会导致此错误。 As swayam said do a Project -> Clean to regenerate your R. 正如swayam所说,做一个Project-> Clean来重新生成R。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.