android - Google Map V2 button couldn't load -


i'm trying add button in google map. upon on click,it show location of place. however, when run it, gave me force close error.

the button make work "city" other 2 of button ,i've yet set it.

here logcat error.

07-22 14:50:19.260: e/androidruntime(11261): fatal exception: main 07-22 14:50:19.260: e/androidruntime(11261): java.lang.nosuchmethoderror: com.example.googlemap.mainactivity.getfragmentmanager 07-22 14:50:19.260: e/androidruntime(11261):    @ com.example.googlemap.mainactivity.oncreate(mainactivity.java:26) 07-22 14:50:19.260: e/androidruntime(11261):    @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1050) 07-22 14:50:19.260: e/androidruntime(11261):    @ android.app.activitythread.performlaunchactivity(activitythread.java:1615) 07-22 14:50:19.260: e/androidruntime(11261):    @ android.app.activitythread.handlelaunchactivity(activitythread.java:1667) 07-22 14:50:19.260: e/androidruntime(11261):    @ android.app.activitythread.access$1500(activitythread.java:117) 07-22 14:50:19.260: e/androidruntime(11261):    @ android.app.activitythread$h.handlemessage(activitythread.java:935) 07-22 14:50:19.260: e/androidruntime(11261):    @ android.os.handler.dispatchmessage(handler.java:99) 07-22 14:50:19.260: e/androidruntime(11261):    @ android.os.looper.loop(looper.java:130) 07-22 14:50:19.260: e/androidruntime(11261):    @ android.app.activitythread.main(activitythread.java:3691) 07-22 14:50:19.260: e/androidruntime(11261):    @ java.lang.reflect.method.invokenative(native method) 07-22 14:50:19.260: e/androidruntime(11261):    @ java.lang.reflect.method.invoke(method.java:507) 07-22 14:50:19.260: e/androidruntime(11261):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:912) 07-22 14:50:19.260: e/androidruntime(11261):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:670) 07-22 14:50:19.260: e/androidruntime(11261):    @ dalvik.system.nativestart.main(native method) 

here coding.

mainactivity.java

public class mainactivity extends  fragmentactivity  {      private final latlng location_burnaby = new latlng(49.27645, -122.917587);     private final latlng location_surrey = new latlng(49.187500, -122.849000);      private googlemap map;       @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          map = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap();     }      public void onclick_city(view v){         cameraupdate update = cameraupdatefactory.newlatlng(location_burnaby);         map.animatecamera(update);     }      public void onclick_burnaby(view v){      }      public void onclick_surrey(view v){      } } 

you should use getsupportfragmentmanager()

supportmapfragment fm = (supportmapfragment)  getsupportfragmentmanager().findfragmentbyid(r.id.map); map = fm.getmap();  

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -