-4
私のアプリケーションで画像を共有したいと思います。メソッド 'setContentUrl'を解決できません
は、これは私のレイアウトファイル
activity_xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.dc.google.MainActivity">
<Button
android:id="@+id/share_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Share on Google+"
/>
</RelativeLayout>
ですこれはここで
package com.example.dc.google;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
Button button;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button shareButton = (Button) findViewById(R.id.share_button);
shareButton.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(View v) {
// Launch the Google+ share dialog with attribution to your app.
Intent shareIntent = shareButton.setText("Welcome to Google+")
.setContentUrl(Uri.parse("https://developers.google.com/+/"))
.getIntent();
startActivityForResult(shareIntent,0);
}
});
}
}
.setContentUrl
MainActivity.java
あるthe method can not be resolved.
を言って、エラーを示してい 解決策が見つかりません。
このエラーを解決するにはどうすればよいですか?
さて、あなたはそのメソッドをどのように呼び出そうとしていますか? 'setText'はvoidメソッドです... –
そして、あなたが何かを見つけることができないと言うとき。 1)エラーメッセージを読んでください。そこには、この3行のコードには間違ったことがたくさんあります。 2)APIのドキュメントを読んでください。 3) 'setContentUrl'は有効なメソッドだと思いますか? –