gpt4 book ai didi

android - 禁用 OnItemLongClickListener 上的 onItemclicklistener

转载 作者:行者123 更新时间:2023-11-29 00:31:35 26 4
gpt4 key购买 nike

我想在长按时禁用 onItemclicklistener。问题是我正在 GridView 的 onItemclick 上播放视频。我想在 onItemLongclick 上执行一些其他任务。但是,当我长按它时,它正在播放视频并执行其他一些任务。这是我的代码。

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;
}
});
}

最佳答案

尝试将您的 OnItemLongClickListener 返回值设置为 true 以告知回调已被使用。如果您返回 false,它认为长按没有被消耗。这可能会解决您的问题

关于android - 禁用 OnItemLongClickListener 上的 onItemclicklistener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15332508/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com