Fixed
Status Update
Comments
il...@google.com <il...@google.com>
jb...@google.com <jb...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit b84932eaa562fbba687614cd944b32370f4803e8
Author: Sanura N'Jaka <sanura@google.com>
Date: Tue May 04 03:07:40 2021
Add an API to get the fragment that was most recently added
to a FragmentContainerView
Adding an API to get the fragment that was most recently added
to the calling FragmentContainerView. This allows users to get the
fragment directly from the FragmentContainerView, instead of having
to go through the FragmentManager.
RelNote: "`FragmentContainerView` now provides `getFragment()`,
which returns the fragment that was most recently added to the container."
Bug: 162527857
Test: FragmentContainerViewTest.kt
Change-Id: Ife17ac3a7afe345a8a2e8e1bdf9281fabd63a2d1
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentContainerViewTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentContainerView.java
https://android-review.googlesource.com/1695365
Branch: androidx-main
commit b84932eaa562fbba687614cd944b32370f4803e8
Author: Sanura N'Jaka <sanura@google.com>
Date: Tue May 04 03:07:40 2021
Add an API to get the fragment that was most recently added
to a FragmentContainerView
Adding an API to get the fragment that was most recently added
to the calling FragmentContainerView. This allows users to get the
fragment directly from the FragmentContainerView, instead of having
to go through the FragmentManager.
RelNote: "`FragmentContainerView` now provides `getFragment()`,
which returns the fragment that was most recently added to the container."
Bug: 162527857
Test: FragmentContainerViewTest.kt
Change-Id: Ife17ac3a7afe345a8a2e8e1bdf9281fabd63a2d1
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentContainerViewTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentContainerView.java
il...@google.com <il...@google.com> #3
This has been added internally and will be available in the upcoming Fragment 1.4.0-alpha01
release.
Description
Component used: Fragment
Version used: 1.3.0-alpha07
It would be nice to have a way to retrieve the topmost fragment (i.e., the last added fragment) from a
FragmentContainerView
, particularly if it used the same technique asfindViewById()
to cast the Fragment to the right type.This would be particularly helpful when using View Binding or Data Binding where you have easy access to the
FragmentContainerView
instance, but not necessarily to itsR.id
to pass intofindFragmentById()
.With this, you could then write code such as: