Multiple errors compiling in Android Studio [closed]

0

I created a project in Android Studio (yes, the Rotate the device). I finished the main screen and created the action for the Root button. After I created a "Welcome" screen, several errors appeared. One of these are these;

  

Error: (23, 10) error: ')' expected
  Error: (27, 39) error: ';' expected
  Error: (27, 49) error: ';' expected
  Error: (34, 41) error: ';' expected
  Error: (34, 55) error: ';' expected
  Error: (47, 2) Error: reached end of file while parsing
  Error: Execution failed for task ': app: compileDebugJavaWithJavac'.
  Compilation failed; see the compiler error output for details.

This is the Welcome Screen MainActivity:

package com.hyanhythalo.rootfox;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class Main2Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        final Button button = (Button) findViewById(R.id.welcome_ok_button);

        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                finish();
            }
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main2, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
    
asked by anonymous 27.09.2015 / 04:16

1 answer

2

You did not include the closing of the parentheses and the semicolon when declaring the OnClickListener event. The following is the correction:

button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            finish();
        }
});
    
27.09.2015 / 04:50