【发布时间】:2016-04-01 16:25:48
【问题描述】:
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 和共享,所以请帮助我
【问题讨论】:
-
我认为你应该使用
View.OnClickListener -
我该怎么做,请给我一个例子
-
用
View.OnClickListener替换OnClickListener -
现在。 Setonclicklistener 是红色的
标签: java android onclicklistener sharing