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

时间:2013-10-03 17:26:55

标签: android facebook facebook-sdk-3.0

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

我正在尝试在我的项目中添加Facebook SDK。在我的项目 - > properties-> Android(然后添加facebook adk作为库)之后添加它,当我尝试创建我的xml文件并使用它时显示我旁边的红叉并且无论我做什么我不是能够使这个错误消失。请帮助我..感谢任何帮助!!

4 个答案:

答案 0 :(得分:13)

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

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

xmlns:*PREFIX*="http://schemas.android.com/apk/res-auto"

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

<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>

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

答案 1 :(得分:1)

使用

FacebookSdk.sdkInitialize(getApplicationContext());

之前

super.onCreate(savedInstanceState);

答案 2 :(得分:0)

将库和项目保持在同一个工作区中。

答案 3 :(得分:0)

尝试删除这两行  FB:login_text = “@串/ connect_with_facebook”  fb:logout_text =“与facebook连接”