Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook LoginButton for Android does not take login_text and logout_text values passed from XML

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?

like image 559
Gopinath Avatar asked Feb 25 '13 15:02

Gopinath


2 Answers

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>
like image 73
sumitarora Avatar answered Nov 15 '22 21:11

sumitarora


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.

like image 43
Gabriel Oliveira Avatar answered Nov 15 '22 22:11

Gabriel Oliveira