简体   繁体   中英

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM