所以我想在我的Android應用程序中實現一個自定義的Facebook分享按鈕,但到目前爲止,我只設法使用本地的,我導入到我的.xml文件,並製作在我的Java活動中使用該特定頁面。自定義Facebook分享按鈕,Android應用程序
我的代碼看起來像這樣(在.xml中);
<com.facebook.share.widget.ShareButton
android:id="@+id/share_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="Share"
android:layout_centerHorizontal="true"/>
而在我的.java中,外部onCreate();
private ShareButton shareButton;
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("https://developers.facebook.com"))
.setContentTitle("MyTitle")
.build();
Inside onCreate();
shareButton = (ShareButton)findViewById(R.id.share_btn);
shareButton.setShareContent(content);
我將如何去利用,我已經導入XML定製按鈕?如果它不是ShareButton的實例,使用.setShareContent顯然不起作用。提前致謝!
找到任何解決方案?我也陷入了同樣的情況。 –