Fixed
Status Update
Comments
jb...@google.com <jb...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 4707481aa6e0c03da63c1839694a4251a6788bd8
Author: Matthew Fraschilla <fraschilla@google.com>
Date: Tue Oct 01 13:27:07 2019
Create lint warning for fragment tag
The <fragment> tag has a number of short comings:
- You are not allowed to do FragmenTransactions on that ID later
- The fragments are not available until the layout is inflated
This change introduces a lint check to warn developers that they should replace
the fragment tag with FragmentContainerView
Test: new FragmentTagDetectorTest
Bug: 139830056
Change-Id: I0d27070ac773ea17528a75c99dcea99f2f7e1404
A fragment/fragment-lint/src/main/java/androidx/fragment/lint/FragmentIssueRegistry.kt
A fragment/fragment-lint/src/main/java/androidx/fragment/lint/FragmentTagDetector.kt
A fragment/fragment-lint/src/test/java/androidx/fragment/lint/ApiLintVersionsTest.kt
A fragment/fragment-lint/src/test/java/androidx/fragment/lint/FragmentTagDetectorTest.kt
https://android-review.googlesource.com/1131677
https://goto.google.com/android-sha1/4707481aa6e0c03da63c1839694a4251a6788bd8
Branch: androidx-master-dev
commit 4707481aa6e0c03da63c1839694a4251a6788bd8
Author: Matthew Fraschilla <fraschilla@google.com>
Date: Tue Oct 01 13:27:07 2019
Create lint warning for fragment tag
The <fragment> tag has a number of short comings:
- You are not allowed to do FragmenTransactions on that ID later
- The fragments are not available until the layout is inflated
This change introduces a lint check to warn developers that they should replace
the fragment tag with FragmentContainerView
Test: new FragmentTagDetectorTest
Bug: 139830056
Change-Id: I0d27070ac773ea17528a75c99dcea99f2f7e1404
A fragment/fragment-lint/src/main/java/androidx/fragment/lint/FragmentIssueRegistry.kt
A fragment/fragment-lint/src/main/java/androidx/fragment/lint/FragmentTagDetector.kt
A fragment/fragment-lint/src/test/java/androidx/fragment/lint/ApiLintVersionsTest.kt
A fragment/fragment-lint/src/test/java/androidx/fragment/lint/FragmentTagDetectorTest.kt
il...@google.com <il...@google.com> #3
This Lint rule will ship as part of Fragments 1.2.0-beta01 (there's no additional steps you need to enable this Lint rule, just upgrade the Fragment library).
b9...@gmail.com <b9...@gmail.com> #4
il...@google.com <il...@google.com> #5
Replace <fragment> with FragmentContainerView. As per this tweet (https://twitter.com/ianhlake/status/1182006577261268993 ), we'll be updating documentation across d.android.com after this release goes stable.
11...@gmail.com <11...@gmail.com> #6
I've tried this fix and failed; Got it working after replacing `android:name="androidx.navigation.fragment.NavHostFragment"` with my start destination fragments' name.
Is this the intended way of using `FragmentContainerView` with navigation? Or am I confused(as per usu...)?
Thanks,
Jon.
Is this the intended way of using `FragmentContainerView` with navigation? Or am I confused(as per usu...)?
Thanks,
Jon.
11...@gmail.com <11...@gmail.com> #7
Scratch my comment.
Changing the name attr only "works" for a single fragment activity. Sorry.
I ended up reverting back to <fragment/> for now.
Changing the name attr only "works" for a single fragment activity. Sorry.
I ended up reverting back to <fragment/> for now.
il...@google.com <il...@google.com> #8
We're tracking a bug with FragmentContainerView with parsing attributes not working, something that NavHostFragment in particular requires.
Feel free to starhttps://issuetracker.google.com/issues/142421837 to track progress on the fix (and for now just continue to use <fragment> for those cases).
Feel free to star
bi...@mail.de <bi...@mail.de> #9
Please only suggest the lint fix if the <fragment> is inside a FrameLayout and/xor is the only child of the parent layout.
In my case I want to inflate a Fragment provided by some lib in my in some nested LinearLayout and the replacement doesn't make sense at all in this case.
il...@google.com <il...@google.com> #10
Re #9 - You should always, always inflate a fragment into a FragmentContainerView
. There is no exception where you should continue to use <fragment>
. You can, of course, put your FragmentContainerView
in any layout you want, LinearLayout
or otherwise.
Description
Version used: 1.2.0-alpha02
Once FragmentContainerView supports android:name (from