Facebook Sdk for Android does not take login_text and logout_text values passed from XML. It just ignores it. There is no documentation/example available on earth which uses this customization of the button.
<com.facebook.widget.LoginButton
xmlns:fb="http://schemas.android.com/apk/res-auto"
android:id="@+id/connectWithFbButton"
style="@style/com_facebook_loginview_default_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:text="@string/connect_with_facebook"
fb:login_text="@string/connect_with_facebook"
fb:logout_text="Connecting with facebook" />
It always says Login In or Log Out. How can I use this property? I tried debugging through the LoginButton code but in vain. It never goes through any of the constructors of LoginButton() and hence cannot parse my custom parameters.
Did someone face this issue?
Solved!!
Add string with name "com_facebook_loginview_log_in_button" to strings.xml located in res>values>strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="com_facebook_loginview_log_in_button">Connect</string>
<string name="com_facebook_loginview_log_out_button">Your Logout</string>
</resources>
Your first solution is correct. It didn't worked because you've defined the style atrribute:
style="@style/com_facebook_loginview_default_style"
From the LoginButton source code:
public LoginButton(Context context, AttributeSet attrs) {
super(context, attrs);
if (attrs.getStyleAttribute() == 0) {
do stuff ...
}
}
So, it will only look at the defined attribute "login_text" if you leave "style" attribute undefined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With