java - Implementing a Gallery with pinch zoom -
i have gallery of images , i'm trying enable pinch zoom on it. separately, work fine. problem is, can't life of me bind 2 of them together! tried bind imagezoomview in imageadapter, no avail. should try doing when user clicks image? have other ideas? code in imageadapter.class returns gallery elements:
public view getview(int position, view convertview, viewgroup parent) { imageview = new imageview(mcontext); bitmap bitmap = bitmapfactory.decoderesource(mcontext.getresources(),mimageids[position]); i.setlayoutparams(new gallery.layoutparams(300, 450)); i.setscaletype(imageview.scaletype.fit_xy); i.setbackgroundresource(mgalleryitembackground); i.setimagebitmap(bitmap); return i; }
and how handle in mainactivity.class:
public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.gallery); gallery g = (gallery) findviewbyid(r.id.gallery); g.setadapter(new imageadapter(this)); log.i("blah","e ok"); g.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view v, int position, long id) { // mbitmap = imageadapter.mimageids[position]; // mzoomview = (imagezoomview)findviewbyid(r.id.zoomview); // mzoomview.setzoomstate(mzoomcontrol.getzoomstate()); // mzoomview.setimage(mbitmap); // toast.maketext(mainactivity.this, "" + position, toast.length_short).show(); } });
as can see, tried something, app crashes. :( here appreciated.
you should create imagezoomview
in getview
method, assuming imagezoomview widget of own subclassing imageview widget.
Comments
Post a Comment