07 Mar 2011, 23:31
Generic-user-small

Timothy Poletti (4 posts)

When setting up the click listeners, I get (4)errors saying that findViewById cannot be resolved. All of the quick fixes only seem to make the errors worse or create new files that I do not really understand. I don’t think there is, but is there a problem with my code? Am I missing part of the SDK somehow?

here is my code in sudoku.java:

public class Sudoku extends Activity implements OnClickListener { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);

// Set up click listeners for all the buttons
    View continueButton = findViewById=(R.id.continue_button);
    continueButton.setOnClickListener(this);
    View newButton = findViewById=(R.id.new_button);
    newButton.setOnClickListener(this);
    View aboutButton = findViewById=(R.id.about_button);
    aboutButton.setOnClickListener(this);
    View exitButton = findViewById=(R.id.exit_button);
    exitButton.setOnClickListener(this);
}

Thank you to anyone who can help.

07 Mar 2011, 23:33
Generic-user-small

Timothy Poletti (4 posts)

I’m sorry about the formatting as well, I am new to programming and this forum.

public class Sudoku extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

     // Set up click listeners for all the buttons
        View continueButton = findViewById=(R.id.continue_button);
        continueButton.setOnClickListener(this);
        View newButton = findViewById=(R.id.new_button);
        newButton.setOnClickListener(this);
        View aboutButton = findViewById=(R.id.about_button);
        aboutButton.setOnClickListener(this);
        View exitButton = findViewById=(R.id.exit_button);
        exitButton.setOnClickListener(this);

    }
    
07 Mar 2011, 23:37
Generic-user-small

Austin Warren (13 posts)

try this.

In eclipse,

click Project -> Clean
then Project -> Build

This should take care of the issue. If not please let me know.

Cheers,

Austin

08 Mar 2011, 01:23
Generic-user-small

Timothy Poletti (4 posts)

I tried that before posting. Usually saving and project->clean fixes most things, but build is grayed out and I don’t know how to use it/ungray it.

08 Mar 2011, 12:30
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

You’ve got extra equals signs in your source. For example

View newButton = findViewById=(R.id.new_button);

should be:

View newButton = findViewById(R.id.new_button);

BTW the Build command is grayed out because you have Build Automatically turned on. That’s the way it should be.

08 Mar 2011, 15:09
Generic-user-small

Timothy Poletti (4 posts)

Thank you! I cannot believe I could not see that after staring at the book and what I wrote for so long.

09 Mar 2011, 03:27
Burnette_ed_pragsmall

Ed Burnette (1316 posts)

Spotting these will get easier with experience.

  You must be logged in to comment