如何限制AutoCompleteTextView下拉菜单? [英] How to restrict AutoCompleteTextView dropdown dismiss?

查看:228
本文介绍了如何限制AutoCompleteTextView下拉菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个 AutoCompleteTextView 。当用户键入 AutoCompleteTextView 时,我会得到一些结果,这些是必须选择的。
但问题是在srceen中的任何位置点击时自动关闭。
我想避免这个。
有什么办法可以实现这个。

I am working on a AutoCompleteTextView . I get some results when the users type in the AutoCompleteTextView and these are mandatory to select. But the problem is the drop down automatically dismisses when clicking on anywhere in the srceen. I want to avoid this. Is there any way I can achieve this.

谢谢。

推荐答案

private boolean setForceIgnoreOutsideTouchWithReflexion(boolean forceIgnoreOutsideTouch) {
    try {
        Method method = android.widget.AutoCompleteTextView.class.getMethod("setForceIgnoreOutsideTouch", boolean.class);
        method.invoke(this, forceIgnoreOutsideTouch);
        return true;
    } catch (Exception e) {
        return false;
    }
}

只有反映在 public class CustomAutoCompleteTextView扩展AutoCompleteTextView ,但是 - 也许这不是一个很好的解决方案

Only reflexion in public class CustomAutoCompleteTextView extends AutoCompleteTextView, but - maybe this not a good solution too

这篇关于如何限制AutoCompleteTextView下拉菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆