android - onLongClick should only happen if condition is true -
this part of code:
if(user.getuserid().equals(thislike.getuserid())) { log.i("on marker click", "equal user id!"); toast.maketext(getapplicationcontext(), r.string.longpress, toast.length_short).show(); markerimage.setonlongclicklistener(new view.onlongclicklistener() { @override public boolean onlongclick(view v) { log.i("on marker click", "onlongclick happens!"); if(user.getuserid().equals(thislike.getuserid())) { log.i("on marker click", "equal user id!"); opencontextmenu(markerimage); return true; } else { log.i("on marker click", "not equal user id!!"); return false; } } }); } else { log.i("on marker click", "f...off!"); return false; }
it describes behavior within onmarkerclick
on googlemap
marker
.
what want happen contextmenu
open when user.getuserid()
equal thislike.getuserid()
i have tried adding markerimage.setonlongclicklistener(null);
on both else statements. did not work..
while solution not perfect... i've added if-check oncreatecontextmenu
this:
@override public void oncreatecontextmenu(contextmenu menu, view v, contextmenu.contextmenuinfo menuinfo) { super.oncreatecontextmenu(menu, v, menuinfo); if(user.getuserid().equals(thislike.getuserid())) { menu.setheadertitle("image options"); getmenuinflater().inflate(r.menu.context_menu_image, menu); } }
it respecting if-check, still know why if-check onlongclick
isn't helping.
Comments
Post a Comment