use*_*716 5 android share facebook-sdk-4.0
我试图在Android中使用Facebook SDK 从我的应用程序共享内容方向.
我在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);
Run Code Online (Sandbox Code Playgroud)
问题是 - 在XML文件中,我需要将com.facebook.share.widget.Sharebutton添加到XML中,但它无法识别.
被com.facebook.share.widget.Sharebutton正确的XML元素添加此Sharebutton?
是的,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" />
Run Code Online (Sandbox Code Playgroud)

小智 4
在主布局中添加这一行
xmlns:facebook="http://schemas.android.com/apk/res-auto"
Run Code Online (Sandbox Code Playgroud)
像这样
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:facebook="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4753 次 |
| 最近记录: |