Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Can';无法让SupportMapFragment返回任何内容..似乎始终为空_Android_Google Maps_Kotlin_Supportmapfragment - Fatal编程技术网

Android Can';无法让SupportMapFragment返回任何内容..似乎始终为空

Android Can';无法让SupportMapFragment返回任何内容..似乎始终为空,android,google-maps,kotlin,supportmapfragment,Android,Google Maps,Kotlin,Supportmapfragment,这是我的代码: 事情的关键是,onMapReady没有被调用,所以我就和 错误 var mapFragment = activity.supportFragmentManager.findFragmentById(R.id.mapF) as SupportMapFragment 进程:com.example.herbstzu.listview,PID:16963 kotlin.TypeCastException:null不能转换为非null类型 com.google.android.g

这是我的代码: 事情的关键是,onMapReady没有被调用,所以我就和

错误

    var mapFragment = activity.supportFragmentManager.findFragmentById(R.id.mapF) as SupportMapFragment
进程:com.example.herbstzu.listview,PID:16963 kotlin.TypeCastException:null不能转换为非null类型 com.google.android.gms.maps.SupportMapFragment

XML

.....
 <LinearLayout
            android:id="@+id/LayoutInfo"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginVertical="10dp"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/imagePhone2"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_gravity="start"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                app:srcCompat="@drawable/ic_exclamation" />

            <TextView
                android:id="@+id/info_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="TextView"
                android:textColor="#000000" />
        </LinearLayout>

        <fragment
            class="com.google.android.gms.maps.MapFragment"
            android:id="@+id/mapF"
            android:layout_width="match_parent"
            android:layout_height="200dp"/>

    </LinearLayout>

</ScrollView>

您使用了错误的片段管理器。您需要使用supportFragmentManager

    var mapFragment = activity.supportFragmentManager.findFragmentById(R.id.mapF) as SupportMapFragment