gpt4 book ai didi

android facebook 喜欢

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:41:38 26 4
gpt4 key购买 nike

我想在我的 Android 应用程序中集成一个赞按钮。我用了代码

likeWebView = (WebView) findViewById( R.id.webView1 );
likeWebView.getSettings().setJavaScriptEnabled(true);
String url = "http://www.facebook.com/plugins/like.php?" +
"href=" + URLEncoder.encode("likeurl" ) + "&" +
"layout=standard&" +
"show_faces=false&" +
"width=500&" +
"action=like&" +
"colorscheme=light&" +
"access_token=" + URLEncoder.encode( "read_stream" );
likeWebView.loadUrl( url );

但登录后显示空白页。请给我一个添加“赞”按钮的解决方案。

最佳答案

终于 Facebook 上线了 Like安卓按钮

步骤:

1 - 添加 Facebook Library到项目

2 - Create App在Facebook上3 - 更新 list

**In the Application tab add meta-data**

<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/fb_id" />

4 - 在布局中添加 LikeView

//activitymain.xml
<com.facebook.widget.LikeView
android:id="@+id/like_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</com.facebook.widget.LikeView>

5 - ActivityMain.java

//set facebook page or link to this like button
LikeView likeView;
UiLifecycleHelper uiHelper;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activitymain);
uiHelper = new UiLifecycleHelper(this, null);
likeView = (LikeView) findViewById(R.id.like_view);
likeView.setObjectId("https://www.facebook.com/<page_username>");//it can be any link

likeView.setLikeViewStyle(LikeView.Style.STANDARD);
likeView.setAuxiliaryViewPosition(LikeView.AuxiliaryViewPosition.INLINE);
likeView.setHorizontalAlignment(LikeView.HorizontalAlignment.LEFT);

}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

uiHelper.onActivityResult(requestCode, resultCode, data, null);

}

输出 enter image description here

关于android facebook 喜欢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8530759/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com