imageview - how to solve onTouchListener android -


i have problem, display image in alert dialog custom, when want add event ontouchlistener image, cannot problem : the method setontouchlistener in type view not applicable. here source code :

public class viewdetailitem extends activity implements ontouchlistener{    bla bla...    onloaditem() } 

here onloaditem() sourcecode :

 imgmain.setimageresource(imgid);         imgmain.setonclicklistener(new onclicklistener() {                       @override             public void onclick(view arg0) {                 // todo auto-generated method stub                 /*intent myintentdetailitem=new intent(getbasecontext(), viewdetailitemfullscreen.class);                 other_class.setitemcode(timgname);                 startactivity(myintentdetailitem);*/                  layoutinflater li = layoutinflater.from(viewdetailitem.this);                 final view inputdialogcustom = li.inflate(r.layout.activity_view_detail_item_fullscreen2, null);                                 final alertdialog.builder alert = new alertdialog.builder(viewdetailitem.this);                    final imageview imgmainbig=((imageview) inputdialogcustom.findviewbyid(r.id.imgmainbig));                 imgid=getbasecontext().getresources().getidentifier(imgname2+"_1", "drawable", getbasecontext().getpackagename());                   imgmainbig.setimageresource(imgid); imgmainbig.setontouchlistener(this);  } } 

the problem refers imgmainbig.setontouchlistener(this);

change this

imgmainbig.setontouchlistener(this); 

to

imgmainbig.setontouchlistener(viewdetailitem.this);  

cause this refers annonymous inner class implements onclicklistener interface.

since activity class implements interface ontouchlistener use viewdetailitem.this


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -