Android programming, a little issue.

前端 未结 3 1813
眼角桃花
眼角桃花 2021-01-26 06:58

I\'m getting the red squiggle under a parenthesis this time, telling me \"insert \"EnumBody\" to complete EnumDeclaration\"

It is happening on the last line of this cod

3条回答
  •  天命终不由人
    2021-01-26 07:18

    Replace your activity code with these lines of code and try compiling again:

    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 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);
    
               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); 
                        } 
                   } 
                } );
        }        
        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);  
            }
        }
    }
    

提交回复
热议问题