Laurence Nicolaou
Laurence Nicolaou

Reputation: 559

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

Upvotes: 1

Views: 2918

Answers (2)

eltabo
eltabo

Reputation: 3807

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.

Upvotes: 0

Swayam
Swayam

Reputation: 16354

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.

Upvotes: 6

Related Questions