这次我得到了括号下的红色波浪线,告诉我“插入“EnumBody”以完成 EnumDeclaration”
它发生在这段代码的最后一行,最后一个括号上;
if (position == 3){
Intent intent = new Intent(Main.this, Progress.class);
Main.this.startActivity(intent); } } } )
这是我的整个活动代码;
package com.example.gymbuddy;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class Main extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.button2).setOnClickListener(new handleButton2());
findViewById(R.id.button3).setOnClickListener(new handleButton3());
findViewById(R.id.button4).setOnClickListener(new handleButton4());
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.work_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
class handleButton2 implements OnClickListener {
public void onClick(View v) {
Intent intent = new Intent(Main.this, Benchmark.class);
startActivity(intent); } }
class handleButton3 implements OnClickListener {
public void onClick(View v) {
Intent intent = new Intent(Main.this, Progress.class);
startActivity(intent); } }
class handleButton4 implements OnClickListener {
public void onClick(View v) {
Intent intent = new Intent(Main.this, Settings.class);
startActivity(intent); } }@
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
if (position == 1){
Intent intent = new Intent(Main.this, Upperbody.class);
Main.this.startActivity(intent); }
if (position == 2){
Intent intent = new Intent(Main.this, Settings.class);
Main.this.startActivity(intent); }
if (position == 3){
Intent intent = new Intent(Main.this, Progress.class);
Main.this.startActivity(intent); } } } )
}