当 ListPopupWindow 非模态时,它不会对单击事件做出反应
我已将 TextWatcher 附加到应用程序中的 EditText 组件,并在文本更改后调用它; (mListPopupWindow 是 ListPopupWindow)
mListPopupWindow = new ListPopupWindow(getActivity());
mListPopupWindow.setAdapter(mAdapter);
mListPopupWindow.setContentWidth(400);
mListPopupWindow.setAnchorView(mRootView);
mListPopupWindow.setModal(false);
mListPopupWindow.setOnItemClickListener(MyFragment.this
mListPopupWindow.setOnDismissListener(MyFragment.this);
mListPopupWindow.show();
如果弹出窗口是使用 setModel(true) 构造的,则我的片段中存在的 OnClick 事件将获取 OnClick 事件。如果弹出窗口不是模态的,它不会获取 Onclick 事件。
我正在使用此视图创建一个建议框,该建议框根据用户在 EditText 中键入的内容更改弹出列表的内容。如果我将弹出窗口设置为模式,则每次用户在 EditText 中输入新字母时,Edittext 组件都会失去焦点。这是非常不酷的:-)
任何人都可以解释如何在 ListPopupWindow 不是模态时获取 Click 事件,或者如何在 EditText 视图下方构造“建议”列表?
I have attached a TextWatcher to an EditText component in my application, and are calling this after the text has changed; (mListPopupWindow is ListPopupWindow)
mListPopupWindow = new ListPopupWindow(getActivity());
mListPopupWindow.setAdapter(mAdapter);
mListPopupWindow.setContentWidth(400);
mListPopupWindow.setAnchorView(mRootView);
mListPopupWindow.setModal(false);
mListPopupWindow.setOnItemClickListener(MyFragment.this
mListPopupWindow.setOnDismissListener(MyFragment.this);
mListPopupWindow.show();
The OnClick event that is present in my fagment gets the OnClick event if the popup is constructed with setModel(true). It does not get the Onclick event if the popup is not modal.
I am using this View to create a Suggest Box that change the contents of the popup list based on what the user is typing in the EditText. If I set the popup window to modal, the Edittext component loses focus every time the user enters a new letter into the EditText. That is very uncool :-)
Can anyone explain how to get Click events when the ListPopupWindow is not modal, or how else to construct a "suggest" list below an EditText View?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题已经不再重要了。我试图实现同样的 AutocompleteTextView 效果。我不知道有这样的观点存在,并试图推出自己的观点。
This question is no longer relevant. I was trying to achieve the same an AutocompleteTextView. I did not know that such a view existed, and tried to roll my own.