0

Hi i am working on map application in which resource ID R.id.map should added automatically to the Android project when you build the layout file. but it giving error and not resolving it automatically. how to resolve it. thanks

mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
user2590541
  • 522
  • 3
  • 7
  • 19

1 Answers1

3

You are not dynamically inserting the framgent, instead you are finding the map fragment using findFragmentById. This means that you need to have the map fragment in your layout file.

You are probably missing the following in your layout file

<fragment
 android:id="@+id/map"
 android:name="com.google.android.gms.maps.MapFragment"
 android:layout_width="match_parent"
 android:layout_height="match_parent" />
Sunil Mishra
  • 3,796
  • 1
  • 27
  • 40