Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict AutoCompleteTextView dropdown dismiss?

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.

Thanks.

like image 277
Syn3sthete Avatar asked Feb 07 '14 10:02

Syn3sthete


1 Answers

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;
    }
}

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

like image 118
ilw Avatar answered Oct 16 '22 17:10

ilw