0

i am currently working with googlemap v2. the problem is that i can't use the class "googlemap" it shows an error. i am using google api 4.2. how can i use this class. xml file code is given below

 <?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> 
user1057197
  • 479
  • 1
  • 6
  • 15

2 Answers2

0

If you use

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

Then you have to use the SupportMapFragment class in your activities. Example:

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

Hope it helps

FrankenBel
  • 86
  • 5
  • Because the error would pop if he tries to cast the class in the activity (as he says it happens in the activity). It happened to me last week. It may not be the reason but i cant post comments on other people's posts =/ – FrankenBel Mar 04 '14 at 16:51
  • You're right, he says he can't use the class especifically, not get the fragment. I missread. Sorry... – FrankenBel Mar 04 '14 at 16:58
0

You need to reference GooglePlay services in your android project and import

import com.google.android.gms.maps.GoogleMap;

https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap

You can follow

http://developer.android.com/google/play-services/setup.html

and Reference

Importing google-play-service library showing a red X next to this reference android

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256