2

i have problem, I am successfully to display image in alert dialog custom, but when I want to add event onTouchListener to the image, i cannot get problem : the method setonTouchListener in Type View is not applicable. Here my 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 to imgmainbig.setOnTouchListener(this);

1 Answer 1

1

Change this

imgmainbig.setOnTouchListener(this); 

to

imgmainbig.setOnTouchListener(ViewDetailItem.this); 

cause this refers to annonymous inner class that implements OnClickListener interface.

Since your Activity class implements interface OnTouchListener use ViewDetailItem.this

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.