Closed diareuse closed 5 years ago
Maybe it is not documented clearly but you can't have manually inserted fragments in the same container that FragNav uses (the library relies on exclusively controlling fragments in the given container).
That's absolutely clear, I'm not controlling fragments within @+id/container
- that's absolutely logical that it wouldn't work.
But on initialisation he clears all fragments from fragmentManager
, which ultimately clears my overlay fragment hence it's inaccessible.
Ehh then you need a seperate fragmentmanager for it too. I'd suggest to have a "RootFragment" and use its fragmentmanager as the root for FragNav, then it will not mess with the activity's fragmentmanager
Wait a second, are you suggesting to nest the fragment deeper so it doesn't clear its mates? like so:
<somelayout>
<fragment
android:id="@+id/overlay_fragment"
android:name="com.example.OverlayFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" /> <!-- This is inaccessible -->
<abstractfragment
android:id="@+id/containerRoot"
android:layout_width="match_parent"
android:layout_height="match_parent"><!-- separate fragment -->
<container for FragNav here>
</abstractfragment>
<somelayout/>
Yes I'm basically suggesting that. I'm not sure if that works out. It seems fragnav relies on being exclusive on the fragmentmanager it works on (not just a container). Maybe this behaviour could be changed (I'm not even sure what I suggested above works, worth a try though)
I will try that, thanks for suggestion. However it still seems more like a workaround than a fix to me though.
It is indeed trying to be exclusive with the parent's fragmentManager
Hey,
I have an issue with initialising this library with additional fragment being added from xml. The fragment added from xml will never be accessible to fragment manager, but is indeed attached to activity. Meaning I will never get non-null result from
supportFragmentManager.findFragmentById() [or tag()]
In my activity I have:
Discovered in 2.4.0, still present in 3.0.0-RC
After removing initialisation (or this library altogether), the fragment remains accessible. Is there a way to handle this with your library or is it just a bug? 🙂