Android ListPopupWindow检测点击列表外部(Android ListPopupWindow Detecting Click outside of list)

编程入门 行业动态 更新时间:2024-10-26 04:26:54
Android ListPopupWindow检测点击列表外部(Android ListPopupWindow Detecting Click outside of list)

我使用的ListPopupWindow,我觉得非常适合这个目的,但有一个例外。 我希望能够检测用户何时从列表中选择一个项目或按下后退按钮。 目前发生的情况是,当在ListPopupWindow列表之外单击某个项目时,我无法确定所点击的内容,并且ListPopupWindow被解散。 理想情况下,我希望用户只能从列表中选择一个项目或按下后退按钮,但是我无法实现这一点。 我搜索了一个答案并进行了数小时的实验,但是我无法达到要求。 据我所知,将模态设置为true或false似乎没有区别。 我显然可以检测到从列表中选择了什么,但是无论用户是按下后退按钮还是单击列表外部,似乎都会关闭ListPopupWindow,并且我无法确定导致它的操作,除非未选择项目。 如何检测或防止用户从列表中选择项目或按下后退按钮?

I'm using ListPopupWindow which I find very suitable for the purpose with one exception. I want to be able to detect when the user does other than select an item from the list or presses the back button. Currently what is happening is that when an item is clicked outside of the ListPopupWindow list I cannot determine what was clicked and the ListPopupWindow is dismissed. Ideally what I would prefer is for the user to only be able to select an item from the list or press the back button, however I cannot achieve that. I've searched for an answer and experimented for hours but I cannot achieve what is required. As far as I can determine, setting modal to either true or false appears to make no difference. I can obviously detect what is selected from the list, however whether the user presses the back button or clicks outside of the list appear to both dismiss the ListPopupWindow and I cannot determine the action that caused it other than an item was not selected. How can I either detect or prevent other than the user selecting an item from the list or pressing the back button?

最满意答案

据我可以确定,这可以使用解决

android.support.v7.widget.ListPopupWindow;

setForceIgnoreOutsideTouch(true)

As far as I can determine, this can be solved using

android.support.v7.widget.ListPopupWindow;

and

setForceIgnoreOutsideTouch(true)

更多推荐

本文发布于:2023-08-06 03:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1444411.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:列表   ListPopupWindow   Android   list   Click

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!