Start To Develop
Start To Develop

Reputation: 31

Newbie - Android coding issue of button

I placed a button and set its id to @+id/ourButton.

Then on the MainActivity.java:

Button myButton = (Button) findViewById(R.id.ourButton);

It looks R.id.ourButton is undeclared or not existing.

Upvotes: 2

Views: 59

Answers (2)

fida1989
fida1989

Reputation: 3249

  1. Clean your project or restart the eclipse.
  2. Look to the imports, the R imported maybe is not correct.
  3. If anything is wrong in your layouts, new updates aren't added to the R file. Look at the errors panel, and possibly to a clean rebuild to see what errors are popping up.

Upvotes: 0

Kevin Joymungol
Kevin Joymungol

Reputation: 1814

You can either do a clean on your project or delete your R file, which will then be regenerated.

Upvotes: 1

Related Questions