我目前正在使用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>
答案 0 :(得分:0)
如果您使用
class="com.google.android.gms.maps.SupportMapFragment"
然后您必须在活动中使用SupportMapFragment类。 例如:
SupportMapFragment mapa;
mapa = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
希望有所帮助
答案 1 :(得分:0)
您需要在Android项目中引用Google Play服务并导入
import com.google.android.gms.maps.GoogleMap;
您可以关注
http://developer.android.com/google/play-services/setup.html
和参考
Importing google-play-service library showing a red X next to this reference android