1

我正在使用 Facebook API 开发一个带有导航“可滚动标签 + 滑动”的 Android 应用程序。现在,当我尝试调用类 UserSettingsFragment facebook API 并膨胀以合并到 TAB 中时,我收到一个我无法解决的错误。

这是代码:

        public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        int fragment_seleccionado =getArguments().getInt(ARG_SECTION_NUMBER);
        switch (fragment_seleccionado)
        {
            case 1:
                View View1 = inflater.inflate(R.layout.login_fb,container, false);
                return View1;
            case 2:
                View View2 = inflater.inflate(R.layout.fragment_main_dummy,
                        container, false);
                TextView dummyTextView2 = (TextView) View2
                        .findViewById(R.id.section_label);
                dummyTextView2.setText("Entra por el 2");
                return View2;
            case 3:[....]

当我尝试充气时失败的“login_fb.xml”文件是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Main$DummySectionFragment" >


<fragment android:layout_height="fill_parent"
          android:layout_width="fill_parent"
          android:id="@+id/login_fragment"
          android:name="com.facebook.widget.UserSettingsFragment" />


</RelativeLayout>

现在,错误日志:

03-31 10:33:19.503: E/AndroidRuntime(631): FATAL EXCEPTION: main
03-31 10:33:19.503: E/AndroidRuntime(631): android.view.InflateException: Binary XML file line #12: Error inflating class fragment
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-31 10:33:19.503: E/AndroidRuntime(631):  at shooterfugio.aquiniela2.Main$DummySectionFragment.onCreateView(Main.java:247)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:871)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1251)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:625)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:431)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.support.v4.view.ViewPager.populate(ViewPager.java:895)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.support.v4.view.ViewPager.populate(ViewPager.java:772)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.support.v4.view.ViewPager.completeScroll(ViewPager.java:1539)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.support.v4.view.ViewPager.computeScroll(ViewPager.java:1422)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.ViewGroup.drawChild(ViewGroup.java:2729)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.View.draw(View.java:10981)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.widget.FrameLayout.draw(FrameLayout.java:450)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.ViewGroup.drawChild(ViewGroup.java:2887)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.View.draw(View.java:10981)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.widget.FrameLayout.draw(FrameLayout.java:450)
03-31 10:33:19.503: E/AndroidRuntime(631):  at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2126)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.ViewRootImpl.draw(ViewRootImpl.java:2026)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1634)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.os.Looper.loop(Looper.java:137)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.app.ActivityThread.main(ActivityThread.java:4424)
03-31 10:33:19.503: E/AndroidRuntime(631):  at java.lang.reflect.Method.invokeNative(Native Method)
03-31 10:33:19.503: E/AndroidRuntime(631):  at java.lang.reflect.Method.invoke(Method.java:511)
03-31 10:33:19.503: E/AndroidRuntime(631):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-31 10:33:19.503: E/AndroidRuntime(631):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-31 10:33:19.503: E/AndroidRuntime(631):  at dalvik.system.NativeStart.main(Native Method)
03-31 10:33:19.503: E/AndroidRuntime(631): Caused by: java.lang.IllegalArgumentException: Binary XML file line #12: Duplicate id 0x7f040019, tag null, or parent id 0x0 with another fragment for com.facebook.widget.UserSettingsFragment
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277)
03-31 10:33:19.503: E/AndroidRuntime(631):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
03-31 10:33:19.503: E/AndroidRuntime(631):  ... 36 more

如何解决?

非常感谢您的帮助,并对我的英语水平低感到抱歉。

4

0 回答 0