这次我在括号下得到红色波浪线,告诉我“插入”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);
}
}
}
);
}