为什么这个 Google + 基本共享不起作用?

Why is this Google + basic sharing not working?

import android.content.Intent;
import android.net.Uri;

import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    Button shareButton = (Button) findViewById(R.id.share_button);
    shareButton.setOnClickListener( 

        new OnClickListener() {

            public void onClick (View v) {
                // Launch the Google+ share dialog with attribution to your app.
                Intent shareIntent = new PlusShare.Builder(this)
                    .setType("text/plain")
                    .setText("Welcome to the Google+ platform.")
                    .setContentUrl(Uri.parse("https://developers.google.com/+/"))
                    .getIntent();

                startActivityForResult(shareIntent, 0);
            }
        }
    );
}

我在 "OnClickListener" 和“(View V)”上遇到错误,而且我几乎是 Java 和 Android 的一个完整的初学者,试图添加一些基本 Google 加上分享所以请帮助我

您不能在 class 块内调用方法,您必须在方法中调用。

public class MainActivity extends AppCompatActivity {

    @Override
    public void onCreate(Bundle savedInstanceState){
        Button shareButton = (Button) findViewById(R.id.share_button);
        shareButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick (View v){
                //your code
            }
        });
    }
}