Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Muhammad Sodikin
Muhammad Sodikin
2,815 Points

stuck with Build an Interactive Story App where it states that " public void onClick (View v){ "...w

public void onClick (View v){

how to correct the error of small v there? because at the Log Cat it shows " error: ';' expected

3 Answers

Jon Kussmann
PLUS
Jon Kussmann
Courses Plus Student 7,254 Points

Ah, that's a tough one to see.

In the line:

mStartButton.setOnClickListener(new View.OnClickListener()); {

You have an extra ");"

The line should be:

mStartButton.setOnClickListener(new View.OnClickListener() {
Muhammad Sodikin
Muhammad Sodikin
2,815 Points

Are you sure? Haha.

how about the (View v) characters, the characters 'v' can't be resolved.

Jon Kussmann
Jon Kussmann
Courses Plus Student 7,254 Points

I would make the change I suggested first. To me it seems as though 'v' cannot be resolved since you are ending that statement early because of the extra ");"

Go ahead and try it... if it doesn't work, we'll figure something else out. :P

Jon Kussmann
PLUS
Jon Kussmann
Courses Plus Student 7,254 Points

Hi,

Could you add the rest of the code to your onClick method? It's hard to tell what's going on without that.

Muhammad Sodikin
Muhammad Sodikin
2,815 Points

Hello, the code is:

import android.content.Intent;

public class MainActivity extends ActionBarActivity {

private EditText mNameField;
private Button mStartButton;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mNameField = (EditText)findViewById(R.id.nameEditText);
    mStartButton = (Button)findViewById(R.id.startButton);

    mStartButton.setOnClickListener(new View.OnClickListener()); {
        @Override
            public void onClick (View v){ 
            String name = mNameField.getText().toString();
            startStory();

        }
    });
}

The Log Cat give is :

Error:(31, 32) error: ';' expected Error:(31, 40) error: ';' expected Error:(36, 10) error: illegal start of expression Error:Execution failed for task ':app:compileDebugJava'.

Compilation failed; see the compiler error output for details.

Muhammad Sodikin
Muhammad Sodikin
2,815 Points

Aha. It was the "):". Lets have a drink. Thx.