AutoCompleteTextView force to show all items

前端 未结 12 1813
隐瞒了意图╮
隐瞒了意图╮ 2020-12-25 08:10

There is a moment in my app, that I need to force to show all items in the suggestion list, no matter what the user has typed. How can I do that?

I tried to do somet

12条回答
  •  难免孤独
    2020-12-25 08:43

    As "ArtOfWarfare" suggested, you can just sub-class and override performFiltering():

    public class My_AutoCompleteTextView extends AutoCompleteTextView {
        public My_AutoCompleteTextView(Context context) {
            super(context);
        }
        public My_AutoCompleteTextView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
        public My_AutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
            super(context, attrs, defStyleAttr);
        }
    
        @Override
        protected void performFiltering(CharSequence text, int keyCode) {
            super.performFiltering("", 0);
        }
    }
    

    I'm using it successfully.

提交回复
热议问题