I try to implement the method into my Button's `onClickListener` and i got an `Syntax Error`. 

Below is my code:

```
// button click event
btnCreateNewEvent.setOnClickListener(new View.OnClickListener() {

public void onClick(View view) {
// Checking for server respond
if (serverRespond() == false) {
           //DO SOMETHING
}

```

Below is my `ServerRespond` outside the `onCreate` method

```
// Check server respond    
public boolean serverRespond() {
boolean success = false;
    try {
        URL url = new URL(url_create_event);
        HttpURLConnection urlcon = (HttpURLConnection) url.openConnection();
        urlcon.connect();
        if (urlcon.getResponseCode() == 200) {
            success = true;
        }
    } catch (Exception e) {
        Log.e(create_error.toString(), "Server is not responding");
    }
    return success;
}

```

ERROR: at `if(serverRespond()==true){` 

```
"The method serverRespond() is undefined for the type new View.OnClickListener(){}"

```