1

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

4
  • Could you please paste the whole code when you declare and initialize your ride and fairground views? Commented Apr 30, 2013 at 16:16
  • 1
    Clean your project in eclipse, uninstall application from phone/emulator and run it again. Commented Apr 30, 2013 at 16:18
  • 3
    try cleaning the project: Project -> Clean Commented Apr 30, 2013 at 16:18
  • And I doubt you really need to cast all the way down to EditText anyway :) TextView type is mostly suitable for code manipulations. Commented Apr 30, 2013 at 16:24

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I got this same error when just swapping the positions of 2 classes inside the same linearlayout on an xml file. Swayam's advice worked for me
Glad to be of help! :)
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.