GridView onItemClick 没有被调用?

发布于 2024-10-17 08:20:53 字数 759 浏览 1 评论 0原文

我有一个带有自定义视图的网格视图。自定义视图是包含一些按钮的视图。当我 onItemClick gridview 创建自定义视图时,一切正常,GridView 理解我想要做什么;但是一旦我 onItemLongClick 自定义视图(由于 onItemClick 创建的),它就根本不注册。我不明白,我总是在 longClick 结束时返回 true。但是,如果我用一个简单的图像视图填充 gridview,两种类型的点击都可以工作...

据我从 android UI 处理文章中读到的,所有侦听器都会自上而下地滴流,所以我认为该事件会在在点击自定义视图之前的网格视图...

有什么想法或想法吗?

@Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
    Log.e("Grid", "Log long click"); 
    mSelect = pos;
    mHold = Bitmap.createScaledBitmap(mGridWidgets[pos].toBitmap(), getWidth()/2, getHeight()/2, true);
    mIsHolding = true;
    setOnTouchListener(mToucher);
    Log.e("Grid", mSelect + "");
    mBoundService.vibrator.vibrate(150);
    return true;
}

I have a gridview with custom views in it. The custom views are view that contain a few buttons. When I onItemClick the gridview to create the custom view, everything works fine, the GridView understands what I am trying to do; but as soon as I onItemLongClick a custom view (that has been created due to an onItemClick), it doesn't register at all. I don't get it, I'm always returning true at the end of the longClick. But if I fill the gridview with a simple image view, both types of click work...

As far as I've read from the android UI handling article all listeners will trickle top-down, so I figured that the event would fire at the gridview before hitting the custom view...

Any thoughts or Ideas?

@Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
    Log.e("Grid", "Log long click"); 
    mSelect = pos;
    mHold = Bitmap.createScaledBitmap(mGridWidgets[pos].toBitmap(), getWidth()/2, getHeight()/2, true);
    mIsHolding = true;
    setOnTouchListener(mToucher);
    Log.e("Grid", mSelect + "");
    mBoundService.vibrator.vibrate(150);
    return true;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你丑哭了我 2024-10-24 08:20:53

我真是傻了。我需要拦截 MotionEvent。

I t'was stupid. I needed to intercept the MotionEvent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文