Android ListView headerview无法响应点击事件,有时当headerview通过键盘模式获得焦点,然后在触摸模式下点击它
Android ListView headerview无法响应点击事件,有时当headerview通过键盘模式获得焦点时,然后在触摸模式下点击它。 回购此场景的步骤: 1.滚动listview直到headerview从视线中消失 2.通过键盘模式让headerview获得焦点 3.在触摸模式下单击标题视图 那么headerview只能响应touch事件,不能响应click事件。但在某些设备中,这种情况不会发生。
期望:headerview 可以在任何时候看到它响应点击事件
Android 版本:2.2/2.3 设备:一些带有轨迹球或硬键盘的设备
我需要headerview可以随时响应点击事件。那么有人可以找出这种情况的原因吗?并给我一些建议来解决这个问题? 任何提示表示赞赏,提前致谢。
Android ListView headerview can't respond to click event, sometimes when the headerview get focus by keybord mode, then click it in touch mode.
Steps to repo this scenario:
1. scroll listview until the headerview disappear from sight
2. make the headerview get the focus by keyboard mode
3. click the headerview in touch mode
then the headerview can only respond to touch event, and can't respond to click event. But in some device, this scenario can't occur.
Expect: the the headerview can respond to click event any time we see it
Android version: 2.2/2.3
Device: some devices with trackball or hard keyboard
I need the headerview can respond to click event any time. So someone can figure out the reason for this scenario? and give me some advice to fix this?
Any tip is appreciated, thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也有同样的问题。我不知道为什么它表现得很奇怪,但我能够通过不使用
addHeaderView()
解决问题。只需添加适配器中的标题作为行的一部分:
mListView.setItemsCanFocus(true);
希望它有帮助!
I had the same problem. I don't know why it's acting weird, but I was able to solve the problem by not using
addHeaderView()
.Just add a header from adapter as part of row:
mListView.setItemsCanFocus(true);
hope it helps!