I'm using a viewPager where one tab is a list view and one tab is a Map. The MapFragment I have defined like so:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
class="com.google.android.gms.maps.SupportMapFragment"
android:id="@+id/map_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Then I have within the onViewCreated function the following line:
val mapFragment = fragmentManager?.findFragmentById(map_fragment.id) as SupportMapFragment
This line throws the error:
android.widget.FrameLayout cannot be cast to com.google.android.gms.maps.SupportMapFragment
Note: I use the onViewCreated() function because within onCreate() I get a null pointer on "map_fragment".
My View Pager does the following to create the fragment:
MapViewFragment.newInstance(location, selection)
I have the right manifests as well for google play and maps.
Why is my fragment being turned into a FrameLayout? Is this expected behavior?