Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit f68a1e3c32b099fc26d4be844079b01559e6a29d
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Sep 05 12:48:57 2019
Allow support for name and tag in FragmentContainerView
This change allows adding a Fragment to a FragmentContainerView using
the android:name attribute. The Fragment is added to the first available
FragmentManager in the view hierarchy. If android:tag is set, the new
Fragment will have the specified tag, otherwise, it will be null.
Test: Added FragmentContainerInflatedFragmentTest
BUG: 139830628
Change-Id: Idee1fc11c5efa6f726f1d527c223da15fd300321
M fragment/fragment/src/androidTest/AndroidManifest.xml
A fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentContainerInflatedFragmentTest.kt
A fragment/fragment/src/androidTest/res/layout/inflated_fragment_container_view.xml
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentContainerView.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
M fragment/fragment/src/main/res/values/attrs.xml
https://android-review.googlesource.com/1115080
https://goto.google.com/android-sha1/f68a1e3c32b099fc26d4be844079b01559e6a29d
Branch: androidx-master-dev
commit f68a1e3c32b099fc26d4be844079b01559e6a29d
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Sep 05 12:48:57 2019
Allow support for name and tag in FragmentContainerView
This change allows adding a Fragment to a FragmentContainerView using
the android:name attribute. The Fragment is added to the first available
FragmentManager in the view hierarchy. If android:tag is set, the new
Fragment will have the specified tag, otherwise, it will be null.
Test: Added FragmentContainerInflatedFragmentTest
BUG: 139830628
Change-Id: Idee1fc11c5efa6f726f1d527c223da15fd300321
M fragment/fragment/src/androidTest/AndroidManifest.xml
A fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentContainerInflatedFragmentTest.kt
A fragment/fragment/src/androidTest/res/layout/inflated_fragment_container_view.xml
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentContainerView.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
M fragment/fragment/src/main/res/values/attrs.xml
jb...@google.com <jb...@google.com> #3
This has been fixed internally and will be available in the Fragment 1.2.0-alpha05 release.
Description
Version used: 1.2.0-alpha02
The <fragment> tag has a number of short comings:
- It does not allow you to do FragmentTransactions on that ID later (it'll overlap after a configuration change)
- It has a slightly different lifecycle in that the Fragments aren't available until after the layout is inflated
It would be really nice if you could use FragmentContainerView and attach an android:name (and optionally an android:tag) and have it do the equivalent of an if (savedInstanceState == null) { // add the Fragment } type of code for you. This would bring together XML added Fragments and programmatically added Fragments into one system.