Question:
Is this syntax correct? am i missing a curly bracket?
Izzy
2012-01-14 11:18:23 UTC
package android.app;
import android.app.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;



public class activity2 extends Activity{

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);

Button next = (Button) findViewById(R.id.Back);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}
Button sound = (Button) findViewById(R.id.sound);
setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MediaPlayer mp = MediaPlayer.create(TestSonido.this, R.raw.slayer);
mp.start();
}
})
;
}
};
}
}
Three answers:
Nace
2012-01-14 11:30:14 UTC
If you use an IDE, or at the very least an editor, they typically show you the corresponding opening brackets for when you type closing ones.
Mikett
2012-01-14 11:26:16 UTC
Actually you have one to many. You have an extra closing bracket. All you have to do is count the number of opening brackets you have and the number of closing brackets you have. Both should be equal.
Marcus S
2012-01-14 11:23:53 UTC
I put it into pastebin to look at it better, and I think the last two curly brackets aren't needed.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...