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);
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.