java - Is it possible to put a Google Maps V2 MapFragment inside an ActionBar tab? -
i have application uses action bar tabs. trying upgrade application use google maps v2 (mapfragment) when mapfragment passed fragment container main activity, crashes.
mapfragment:
public class establishmentgooglemapfragment extends mapfragment { private googlemap mmap; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view root = super.oncreateview(inflater, container, savedinstancestate); mmap = getmap(); return root; } }
fragment transaction:
public void ontabselected(tab tab, fragmenttransaction ft) { if(fragment == null){ string fragmentname = fragmentclass.getname(); fragment = fragment.instantiate(activity, fragmentname); ft.add(fragmentcontainer, fragment, fragmentname); } else { ft.attach(fragment); } }
logcat:
fatal exception: main java.lang.runtimeexception: unable instantiate activity componentinfo{com.rb.hellojson/com.rb.hellojson.establishmentgooglemapfragment}: java.lang.classcastexception: com.rb.hellojson.establishmentgooglemapfragment cannot cast android.app.activity @ android.app.activitythread.performlaunchactivity(activitythread.java:2024) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2125) @ android.app.activitythread.access$600(activitythread.java:140) @ android.app.activitythread$h.handlemessage(activitythread.java:1227) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:4898) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1006) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:773) @ dalvik.system.nativestart.main(native method) caused by: java.lang.classcastexception: com.rb.hellojson.establishmentgooglemapfragment cannot cast android.app.activity @ android.app.instrumentation.newactivity(instrumentation.java:1057) @ android.app.activitythread.performlaunchactivity(activitythread.java:2015) ... 11 more
this error should clear:
caused by: java.lang.classcastexception: com.rb.hellojson.establishmentgooglemapfragment cannot cast android.app.activity
are trying startactivity on fragment or what?
for later fixes: mmap = getmap();
return null @ point (or maybe not).
edit:
something starting fragment activity. , if it's not launcher, because fragment defined in manifest...
Comments
Post a Comment