简体   繁体   English

java.lang.ClassCastException:android.widget.TextView无法转换为android.widget.EditView

[英]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.

相关问题 java.lang.ClassCastException:无法转换android.widget.TextView - java.lang.ClassCastException: android.widget.TextView cannot be cast Android: java.lang.ClassCastException: android.widget.imageView 无法转换为 android.widget.textView - Android: java.lang.ClassCastException: android.widget.imageView cannot be cast to android.widget.textView Android java.lang.ClassCastException:android.widget.LinearLayout无法强制转换为android.widget.TextView - Android java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView java.lang.ClassCastException:android.widget.TextView无法转换为android.widget.EditText - java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText java.lang.ClassCastException:android.widget.ScrollView无法强制转换为android.widget.TextView - java.lang.ClassCastException: android.widget.ScrollView cannot be cast to android.widget.TextView 造成原因:java.lang.ClassCastException:android.widget.RelativeLayout无法转换为android.widget.TextView - Caused by: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView java.lang.ClassCastException:android.widget.ImageButton无法转换为android.widget.TextView - java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.TextView java.lang.ClassCastException:android.widget.LinearLayout 无法转换为 android.widget.TextView - java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView java.lang.ClassCastException:androidx.constraintlayout.widget.ConstraintLayout 无法转换为 android.widget.TextView - java.lang.ClassCastException: androidx.constraintlayout.widget.ConstraintLayout cannot be cast to android.widget.TextView java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageView 不能转换为 android.widget.TextView - java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageView cannot be cast to android.widget.TextView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM