我怎样才能在preferenceScreen整合Facebook LoginButton [英] How can I integrate Facebook LoginButton in PreferenceScreen

查看:170
本文介绍了我怎样才能在preferenceScreen整合Facebook LoginButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想给我的用户通过设置屏幕,使用简单/断开连接到Facebook的能力 preferenceScreen

I want to give my users ability to connect/disconnect to Facebook through Settings screen which uses simple PreferenceScreen

我如何能整合在 preferenceScreen 这个自定义按钮。 <一href="https://developers.facebook.com/docs/reference/android/current/LoginButton/">https://developers.facebook.com/docs/reference/android/current/LoginButton/

How can I integrate this custom Button class in PreferenceScreen. https://developers.facebook.com/docs/reference/android/current/LoginButton/

登录按钮大大简化,否则需要手动完成,如果我提供简单的 preference 和使用 onClickListener

The login button greatly simplifies session management which otherwise needs to be done manually, if I provide simple Preference and use onClickListener

推荐答案

我会做的是创建一个包含你的preference的登录按钮使用的LinearLayout嵌入自定义XML。使用LinearLayout中是很重要的,因为它处理的onClick事件的方式是最低的孩子的onClickListener过父母onClickListener获得优先权。这意味着,只有时间登录按钮的onClick逻辑被称为是当用户直接水龙头上的按钮。

What I would do is create a custom XML which contains your preference with the login button embedded using a LinearLayout. Using LinearLayout is important because the way it handles onClick events is that the lowest child with an onClickListener gets priority over a parent onClickListener. This means that the only time your login button's onClick logic is called is when the user directly taps on the button.

在code,你现在可以延长preferenceFragment类在这里你可以设置onClick的监听器和其他任何你可能需要。需要注意的是,如果你支持的API级别10或更低,则可能需要以创建自定义preference使用方法:

In code, you can now extend the PreferenceFragment class where you can set up the onClick listeners and anything else you may need. Note that if you're supporting API level 10 or lower, you may need to use in order to create the custom preference:

addPreferencesFromResource(R.xml.custom_preference);

希望这是你在寻找什么,我AP preciate任何反馈。

Hopefully this is what you're looking for, and I appreciate any feedback.

这篇关于我怎样才能在preferenceScreen整合Facebook LoginButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆