actionbarsherlock sherlockfragment google maps v2 is null -
i'm trying use actionbarsherlock tab bar , in 1 of taps want map. have created map in sherlockfragment google map v2, want add markers programmatically map.
public class map_fragment extends sherlockfragment { static final latlng cph = new latlng(55.702355,12.436523); private final static string map_tag = "map"; private googlemap mmap; supportmapfragment mmapfragment; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate){ supportmapfragment map = (supportmapfragment) (getsherlockactivity().getsupportfragmentmanager().findfragmentbytag(map_tag)); if(map==null){ log.d("map", "null"); } if(map!=null){ log.d("map", " " + map); log.d("getmap", " " + map.getmap()); } //googlemap mmap = map.getmap(); //mmap.movecamera(cameraupdatefactory.newlatlngzoom(cph, 14)); return inflater.inflate(r.layout.mapv2_layout, container, false); } @override public void onviewcreated(view view, bundle savedinstancestate){ super.onviewcreated(view, savedinstancestate); } @override public void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); } @override public void onattach(activity activity) { // todo auto-generated method stub super.onattach(activity); } public void setupmap(){ log.d("success" , "success"); } }
i have tried many different suggestions other sites , posts on stack overflow, map null.
i have tried oncreate , onattach after suggestions others, no luck.
i have tried long time , im pull hair out :(
i solved manually adding sherlockmapfragment class actionbarsherlock library, found here http://code.google.com/p/opendatakit/source/browse/src/com/actionbarsherlock/app/sherlockmapfragment.java?spec=svn.tables.35872cc920b5668de433c6fc81efc86c4970bac1&repo=tables&r=0c1b0212e5b8bb5af8ce2b8e9357cd30e3870084
then following lines got "gmap" wasn't null
supportmapfragment map; map = (supportmapfragment) (getsherlockactivity().getsupportfragmentmanager().findfragmentbyid(r.id.map)); gmap = map.getmap();
Comments
Post a Comment