android - OnLongClickListener() not firing up in adapter class -
in android
pageradapter
class have defined onlongclicklistener
. not working while running. couldn't find problem here, appreciated
code
public class fullscreenimageadapter extends pageradapter { private activity _activity; private arraylist<string> _imagepaths; private layoutinflater inflater; // constructor public fullscreenimageadapter(activity activity, arraylist<string> imagepaths) { this._activity = activity; this._imagepaths = imagepaths; } @override public int getcount() { return this._imagepaths.size(); } @override public boolean isviewfromobject(view view, object object) { return view == ((relativelayout) object); } @override public object instantiateitem(viewgroup container, int position) { touchimageview imgdisplay; button btnclose; inflater = (layoutinflater) _activity .getsystemservice(context.layout_inflater_service); view viewlayout = inflater.inflate(r.layout.layout_fullscreen_image, container, false); imgdisplay = (touchimageview) viewlayout.findviewbyid(r.id.imgdisplay); btnclose = (button) viewlayout.findviewbyid(r.id.btnclose); imgdisplay.setonlongclicklistener(new view.onlongclicklistener() { @override public boolean onlongclick(view v) { // todo auto-generated method stub system.exit(0); return true; } }); imageloader2 imageloader = new imageloader2(_activity); imageloader.displayimage(_imagepaths.get(position), imgdisplay); // close button click event btnclose.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { _activity.finish(); } }); ((viewpager) container).addview(viewlayout); return viewlayout; } @override public void destroyitem(viewgroup container, int position, object object) { ((viewpager) container).removeview((relativelayout) object); } }
Comments
Post a Comment