アプリを開発しています。アプリを保存/コンパイルすると、エラーが発生します
Syntax error, insert ";" to complete Statement
と
Syntax error, insert ")" to complete Expression
ここの一番下}
に:
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
これらのエラーが発生する理由がわかりません。私は自分のコードを調べましたが、開いている () も ; を必要とする場所も見つかりませんでした。私のコードは以下に掲載されています。
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
}
}
}
}
これについて何か助けていただければ幸いです。ご協力ありがとうございました。