GridView onItemClick 没有被调用?
我有一个带有自定义视图的网格视图。自定义视图是包含一些按钮的视图。当我 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我真是傻了。我需要拦截 MotionEvent。
I t'was stupid. I needed to intercept the MotionEvent.