Inspectopedia Help

Fragments should specify an id or tag

Fragments should specify an id or tag

If you do not specify an android:id or an android:tag attribute on a <fragment> element, then if the activity is restarted (for example for an orientation rotation) you may lose state. From the fragment documentation:

"Each fragment requires a unique identifier that the system can use to restore the fragment if the activity is restarted (and which you can use to capture the fragment to perform transactions, such as remove it).

* Supply the android:id attribute with a unique ID.

* Supply the android:tag attribute with a unique string.

If you provide neither of the previous two, the system uses the ID of the container view.

Issue id: MissingId

https://developer.android.com/guide/components/fragments.html

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for Android 2023.3, Qodana for JVM 2023.3

Plugin:

Android, 2022.3.1 Beta 2

Last modified: 13 July 2023