我正在开发一个应用程序。保存/编译我的应用程序时,出现错误
Syntax error, insert ";" to complete Statement
和
Syntax error, insert ")" to complete Expression
在这里的底部}
:
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
我无法弄清楚为什么我会收到这些错误。我查看了我的代码,但没有发现 open () 也没有需要 ; 的地方。我的代码发布在下面。
Stationlist.java
public class StationList extends Activity {
Spinner Spinner1 = (Spinner) findViewById(R.id.spinner1);
Spinner Spinner2 = (Spinner) findViewById(R.id.spinner2);
String Red_Line = this.getString(R.string.Red_Line);
String Blue_Line = this.getString(R.string.Blue_Line);
String Green_Line = this.getString(R.string.Green_Line);
String Orange_Line = this.getString(R.string.Orange_Line);
String Brown_Line = this.getString(R.string.Brown_Line);
String Pink_Line = this.getString(R.string.Pink_Line);
String Purple_Line = this.getString(R.string.Purple_Line);
String Yellow_Line = this.getString(R.string.Yellow_Line);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_station_list);
// Show the Up button in the action bar.
getActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_station_list, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
// http://developer.android.com/design/patterns/navigation.html#up-vs-back
//
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
Spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String selectedValue = arg0.getSelectedItem().toString();
if(selectedValue.equalsIgnoreCase(Red_Line))
{
ArrayAdapter<String> firstAdapter = new ArrayAdapter<String>(StationList.this,R.array.Red_Line);
Spinner2.setAdapter(firstAdapter);//
}
if(selectedValue.equalsIgnoreCase(Blue_Line))
{
ArrayAdapter<String> firstAdapter = new ArrayAdapter<String>(StationList.this,R.array.Blue_Line);
Spinner2.setAdapter(firstAdapter);
}
}
public void sendTest(View a) {
Intent Intent9 = new Intent(StationList.this, TestStation.class);
startActivityForResult(Intent9, 0);
setContentView(R.layout.test_station);
}
public void onBackPressed(){
startActivity(new Intent(StationList.this, MainActivity.class));
finish();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
}
}
我会很感激你能给我的任何帮助。谢谢您的帮助。