googlemapv2中的googlemap类

时间:2014-03-04 16:38:32

标签: android google-maps

我目前正在使用googlemap v2。问题是我不能使用“googlemap”类它显示错误。我正在使用谷歌api 4.2。我怎么能用这个班。 xml文件代码在下面给出

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment"/>

 </RelativeLayout> 

2 个答案:

答案 0 :(得分:0)

如果您使用

class="com.google.android.gms.maps.SupportMapFragment"

然后您必须在活动中使用SupportMapFragment类。 例如:

SupportMapFragment mapa;
mapa = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

希望有所帮助

答案 1 :(得分:0)