I want to disable the onItemclicklistener when I Long click. The thing is I am playing the video on onItemclick of grid view. I want to do some other task on onItemLongclick. But when I long press it is playing the video and doing some other task..Here is my code.
gv.setOnItemClickListener(new OnItemClickListener() {
@SuppressWarnings("deprecation")
public void onItemClick(AdapterView<?> parent, View v,final int position, long id) {
Log.d(TAG, "got in onItemClick of Item "+position);
System.gc();
Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
String[] cols = new String[]{
MediaStore.Video.VideoColumns._ID,
MediaStore.Video.VideoColumns.DISPLAY_NAME,
MediaStore.Video.VideoColumns.DATA};
Cursor c;
c = managedQuery(uri, cols, null, null, MediaStore.Video.VideoColumns.DATE_TAKEN);
c.moveToFirst();
int mPath = c.getColumnIndexOrThrow(MediaStore.Video.VideoColumns.DATA);
c.moveToPosition(position);
String filename = c.getString(mPath);
Log.d(TAG, "video position is " + position+ " video path is " + filename);
Intent intent = new Intent(Isabella_galleryActivity.this, ViewVideo.class);
intent.setDataAndType(uri, "video/*");
intent.putExtra("videofilename", filename);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
gv.setOnItemLongClickListener(new OnItemLongClickListener() {
//@Override
public boolean onItemLongClick(AdapterView<?> parent, View v,
int position, long id) {
Log.d(TAG, "got in onItemLongClick of Item "+position);// TODO Auto-generated method stub
//del_image = (ImageView)findViewById(R.id.video_delet_image);
//del_image.setVisibility(View.VISIBLE);
//gv.setClickable(false);
div.setVisibility(View.VISIBLE);
div.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.w(TAG, "deleting the video");
}
});
return false;
}
});
}
Try setting your OnItemLongClickListener
return value to true to tell that the callback was consumed. If you return false it thinks that the long click wasn't consumed. This might fix your problem