android - Nested fragments and back button cause duplicate id -
i have activity hosts 3 fragments in viewflipper. each of 3 fragments hosts fragments of own. using viewflipper tab control, allows me switch between various "views" in app. works fine, far.
when user inside view, there navigation flow. use:
final fragmenttransaction txn = getchildfragmentmanager() .begintransaction(); txn.replace(r.id.view1_silo_container, new view1fragment()); txn.addtobackstack(null); txn.commit();
to move around inside view. user navigates, call variation of code above replace current fragment new one. again, works fine far.
the problem that, when bottom fragment (a>b>c) , hit button go (c>b) duplicate id error. problem "b" fragment has fragment nested in it. long avoid giving fragment id, there no problem. however, if give fragment id "duplicate id, tag null, or parent id 0x0 fragment".
i don't understand why problem, , haven't found way work around it. doing wrong? there small piece missing?
the answer is:
note: cannot inflate layout fragment when layout includes <fragment>. nested fragments supported when added fragment dynamically.
this can found in android 4.2 apis documentation new nested fragments feature.
once removed <fragment> layout , used getchildfragmentmanager() insert fragment 'manually' in oncreateview, worked fine. no more duplicate errors.
Comments
Post a Comment