com.facebook.widget.loginbutton xml中的错误

Shi*_*hah 5 android facebook facebook-sdk-3.0

我知道,一旦我在stackOverflow上发布这个问题,它就会被标记为重复,但请相信我,我已经尝试了在StackOverflow中相同主题下讨论的所有可能的解决方案.

我想在我的项目中添加Facebook SDK.在我的项目 - > properties-> Android下添加它(然后添加facebook adk作为库),当我尝试创建我的xml文件并使用它显示我旁边的红十字会,无论我做什么,我都无法让这个错误消失.请帮帮我.感谢任何帮助!!

jim*_*thy 13

"未绑定前缀"错误是由于xml中的自定义命名空间未被考虑.

您需要在文件顶部添加另一个前缀.它应该类似于我在下面写的内容,但是PREFIX替换为您使用的前缀.

xmlns:*PREFIX*="http://schemas.android.com/apk/res-auto"
Run Code Online (Sandbox Code Playgroud)

所以,最后,你的文件应该是这样的:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fb="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">

    <com.facebook.widget.LoginButton
    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" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

在这个例子中,我添加了前缀'fb',并在使用字段login_text和logout_text时引用了它