java.lang.IllegalArgumentException:找不到id的视图(使用Build Tools> 23.0.1)

时间:2016-09-15 00:33:10

标签: android android-fragments

由于新版本(或者我无法编译Firebase或Google Play服务,我不得不放弃我的buildToolsVersion '23.0.1'并开始使用大于startActivity的版本。

我遇到的问题是当我 java.lang.IllegalArgumentException: No view found for id 0x7f0f028c (com.pronuntiapp.debug.uat:id/root_frame) for fragment PeticionesFragment{f7650f6 #5 id=0x7f0f028c} at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1059) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252) at android.support.v4.app.BackStackRecord.popFromBackStack(BackStackRecord.java:971) at android.support.v4.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1670) at android.support.v4.app.FragmentManagerImpl$2.run(FragmentManager.java:577) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:152) at android.app.ActivityThread.main(ActivityThread.java:5497) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 时我遇到了这个崩溃(所以我认为Fragment会循环使用):

PeticionesFragment

我的RootPeticionesFragment是从先前片段(public class RootPeticionesFragment extends BaseFragment { View view; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.root_fragment, container, false); FragmentTransaction transaction = getActivity().getSupportFragmentManager() .beginTransaction(); transaction.replace(R.id.root_frame, new PeticionesFragment()); try { transaction.commit(); } catch (Exception e) { e.printStackTrace(); } return view; } } )填充的片段,该片段位于ViewPager中。

RootPeticionesFragment.java

<FrameLayout 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:id="@+id/root_frame" >

</FrameLayout>

root_fragment.xml

                            if (container == null && !f.mRestored) {
                                throwException(new IllegalArgumentException(
                                        "No view found for id 0x"
                                        + Integer.toHexString(f.mContainerId) + " ("
                                        + f.getResources().getResourceName(f.mContainerId)
                                        + ") for fragment " + f));
                            }

因为FragmentManager上的这个部分而崩溃了

container

以前的buildTools中不存在。 我调试了代码,array[09]为空。

不让它崩溃的魔术是什么?它一直都有效。

干杯!

0 个答案:

没有答案