我正在尝试在 android 中实现一个微调器,当我这样做时,我遇到了这个奇怪的语法错误,我无法解决它。
我正在编写的代码:
public class AddContact extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_contact);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.add_contact, menu);
return true;
}
Spinner spinner = (Spinner) findViewById(R.id.contact_number_array);
//Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> Adapter = ArrayAdapter.createFromResource(this, R.array.phone_array, android.R.layout.simple_spinner_item);
//Specify the layout to use when the list of choices appears
Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}
当我在写“Adapter.setDropDownViewResource ....”时,我收到了这个奇怪的错误,这是堆栈跟踪:
Multiple markers at this line
- Syntax error, insert "}" to complete ClassBody
- Syntax error, insert "enum Identifier" to complete
EnumHeaderName
- Syntax error on token "Adapter", delete this token
- Syntax error, insert "EnumBody" to complete EnumDeclaration
我无法弄清楚问题是什么。有人可以帮忙吗?