/*长按gallery中的图片进行删除该图片的操作*/
gallery.setOnItemLongClickListener(new OnItemLongClickListener(){
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
final int arg2, long arg3) {
// TODO Auto-generated method stub
new AlertDialog.Builder(SdcardActivity.this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("温馨提示")
.setMessage("您真的要删除这个图片吗")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
File file=new File(Constants.path+imageNames[arg2]);
if(file.exists()){
file.delete();
}
}
})
.setNegativeButton("取消", null)
.show();
return true;
}
});
}