Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find method getFragment() in my FragmentContainerView object

In the XML I have

<androidx.fragment.app.FragmentContainerView
    android:id="@+id/identifications_map_view"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:visibility="gone"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

I would like to get the Fragment from the View. The documentation suggests to use

FragmentContainerView fcv = findViewById(R.id.identifications_map_view);
SupportMapFragment smf = fcv.getFragment()

But Android Studio cannot resolve symbol, and if I CTRL+Click the "FragmentContainerView" it doesn't show getFragment() when i search with CTRL+F.

I know there is another way to get the Fragment but I was wondering why I can't do it this way. I guess there is some problem with the version, because I seem to have an older version of the class than the documentation's, for example there is also an extra constructor that uses the FragmentManager, nowhere to be found in the documentation. Could it even be minimum API problem? I have 24.

Thanks.

like image 571
DrMontorsi Avatar asked Jun 17 '21 11:06

DrMontorsi


1 Answers

It has been added from 1.4.0-alpha01 (https://developer.android.com/jetpack/androidx/releases/fragment#1.4.0-alpha01)

If you are on a lower version it won't be there.

like image 61
Sam Pengilly Avatar answered Oct 05 '22 12:10

Sam Pengilly