Android Google Maps API V2.0-包括XML格式的MapView

Android Google Maps API V2.0-包括XML格式的MapView,android,android-maps,Android,Android Maps,我试图在片段中插入MapView,但找不到将MapView对象强制转换到的正确类 我像这样将地图视图插入到我的片段中 <com.google.android.gms.MapView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/map_view_track"/> 然而,我不可避免地会得到一个ClassCastException

我试图在片段中插入MapView,但找不到将MapView对象强制转换到的正确类

我像这样将地图视图插入到我的片段中

<com.google.android.gms.MapView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/map_view_track"/>
然而,我不可避免地会得到一个ClassCastException


可以这样插入地图视图吗?我敢肯定是的。

com.google.android.gms.Maps并不是作为一个类存在的,好吧。试试com.google.android.gms.maps.MapView。

com.google.android.gms.maps不作为类存在,AFAIK。试试com.google.android.gms.maps.MapView。

你又来了。我也有你的书,觉得它非常有用。Thanks@DiscoS2:你能发布你的堆栈跟踪吗?我很高兴你喜欢这本书。问题解决了。这只是一个找到正确类的例子。我只是在用com.google.android.gms.MapView或com.google.android.gms.maps.MapView,你又来救我了。我也有你的书,觉得它非常有用。Thanks@DiscoS2:你能发布你的堆栈跟踪吗?我很高兴你喜欢这本书。问题解决了。这只是一个找到正确类的例子。我只是在使用com.google.android.gms.MapView或com.google.android.gms.maps.MapView