android - The Popup window cannot function on Marker -
good morning
at here try add popup window function on marker click when launching app, popup not function. , try solve still cannot solve problem.
this java code
package com.everstudio.nadejenew; import android.os.bundle; import android.support.v4.app.fragment; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.button; import android.widget.framelayout; import android.widget.popupwindow; import android.widget.relativelayout; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.onmapreadycallback; import com.google.android.gms.maps.supportmapfragment; import com.google.android.gms.maps.model.latlng; import com.google.android.gms.maps.model.marker; import com.google.android.gms.maps.model.markeroptions; import static android.content.context.layout_inflater_service; public class locationfragment extends fragment implements onmapreadycallback { static view view; private googlemap mmap; private relativelayout dialog_popup; marker m1; public locationfragment() { // required empty public constructor } public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { if (view == null) { view = inflater.inflate(r.layout.fragment_location, container, false); supportmapfragment mapfragment = (supportmapfragment) getchildfragmentmanager().findfragmentbyid(r.id.map); mapfragment.getmapasync(this); } return view; } @override public void onmapready(googlemap googlemap) { mmap = googlemap; mmap.setmaptype(googlemap.map_type_normal); // add marker in sydney , move camera latlng location = new latlng(2.1895696, 102.2478482); m1 = mmap.addmarker(new markeroptions().position(location).title("location")); mmap.setonmarkerclicklistener(new googlemap.onmarkerclicklistener() { @override public boolean onmarkerclick(marker marker) { layoutinflater inflater = (layoutinflater) getactivity().getsystemservice(layout_inflater_service); view popupview = inflater.inflate(r.layout.marker_popup, null); final popupwindow popupwindow = new popupwindow( popupview, framelayout.layoutparams.wrap_content, framelayout.layoutparams.wrap_content); button btndismiss = (button)popupview.findviewbyid(r.id.dismissbtn); btndismiss.setonclicklistener(new button.onclicklistener(){ @override public void onclick(view v) { // todo auto-generated method stub popupwindow.dismiss(); }}); return true; } }); } }
you missing popupwindow.showasdropdown(popupview);
Comments
Post a Comment