在Android GridView上实现onItemClick和onItemLongClick [英] Implementing onItemClick and onItemLongClick on an Android GridView

查看:177
本文介绍了在Android GridView上实现onItemClick和onItemLongClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为GridView实现onItemLongClickonItemClick,以使GridView项对两个事件都做出响应?

How do I implement onItemLongClick and onItemClick for a GridView so that GridView items respond to both events?

推荐答案

我发现窍门在longclick监听器回调的返回值中.如果返回true,则在调用longclick之后将不会调用onclick,而简单的单击将仅调用onclick.对我来说很好.

I found that the trick is in the return value of the longclick listener call back. If you return true, onclick will not be called after the longclick is called and simple click will invoke only onclick. It worked fine for me.

这篇关于在Android GridView上实现onItemClick和onItemLongClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆