Android : This method requires a body instead of semicolon

on Friday, August 8, 2014


I don't know maybe I am so exhausted that I can not figure out my obvious mistake, but if you can help me, you let me go to sleep :)


Here I create a method in order to add a Spinner inside a dialog in my android application:



public void spinnerGenerate(String[] s){

ArrayAdapter<String> adb = new ArrayAdapter<String>(MtActivity.this,R.layout.simple_spinner_item, s);
Spinner sp = new Spinner(MtActivity.this);
sp.setAdapter(adb);

AlertDialog.Builder builder = new AlertDialog.Builder(MtActivity.this);
builder.setView(sp);
builder.create().show();


}


Now I want to test it, so I define a String array and call the method:



String[] testArray = {"aaa","bbb","ccc","ddd"};
spinnerGenerate(testArray);


BUT, I have got these errors:



Return type for the method is missing
This method requires a body instead of a semicolon
Syntax error on token "testArray", VariableDeclaratorId expected after this token

0 comments:

Post a Comment