android - Need help! How to get info from another class and use on a Google Mark -
i have class called cadactivity define tittle mark using edittext. how can use information inside onmaplongclick?
any great :)
public class mapaactivity extends fragmentactivity implements googlemap.onmaplongclicklistener { googlemap map; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.mapa); android.support.v4.app.fragmentmanager myfragment = getsupportfragmentmanager(); supportmapfragment meusupfragment = (supportmapfragment)myfragment.findfragmentbyid(r.id.map); map = meusupfragment.getmap(); map.setmylocationenabled(true); map.setonmaplongclicklistener(this); } @override public void onmaplongclick(latlng coord) { //intent cadmap = new intent(this,cadastraractivity.class); //startactivity(cadmap); map.addmarker(new markeroptions() .position(coord) .title("") .icon(bitmapdescriptorfactory.defaultmarker(bitmapdescriptorfactory.hue_blue))); } }
you need reference in method, (notice edittext variable, call layout reference , setting title using text in it):
public class mapaactivity extends fragmentactivity implements googlemap.onmaplongclicklistener { googlemap map; edittext mytext; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.mapa); android.support.v4.app.fragmentmanager myfragment = getsupportfragmentmanager(); supportmapfragment meusupfragment = (supportmapfragment)myfragment.findfragmentbyid(r.id.map); mytext = (edittext)myfragment.findfragmentbyid(r.id.name_of_your_edit_text); map = meusupfragment.getmap(); map.setmylocationenabled(true); map.setonmaplongclicklistener(this); } @override public void onmaplongclick(latlng coord) { //intent cadmap = new intent(this,cadastraractivity.class); //startactivity(cadmap); map.addmarker(new markeroptions() .position(coord) .title(mytext.gettext().tostring()) .icon(bitmapdescriptorfactory.defaultmarker(bitmapdescriptorfactory.hue_blue))); } }
Comments
Post a Comment