我正在尝试在 Android 中使用 Facebook SDK 来 Share Content来 self 的应用的方向。
我在 Facebook Docs 上使用以下代码:
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("http://www.focusoutdistractions.com/"))
.build();
ShareButton shareButton = (ShareButton) rootView.findViewById(R.id.ibtn_twshare);
shareButton.setShareContent(content);
问题是 - 在 XML 文件中,我需要将 com.facebook.share.widget.Sharebutton 添加到 XML,但它没有被识别。 p>
com.facebook.share.widget.Sharebutton 是要为此 Sharebutton 添加的正确 XML 元素吗?
最佳答案
是的,com.facebook.share.widget.ShareButton
是正确的 XML 元素。它不会通过 XML 布局的预览来呈现,但不用担心。该应用程序将毫无问题地编译,并且运行应用程序将正确显示它。
<com.facebook.share.widget.ShareButton
android:id="@+id/shareButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
关于android - 无法将 com.facebook.share.widget.Sharebutton 添加到布局 XML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29340092/