AutocompleteTextview未显示建议

时间:2014-08-06 12:27:49

标签: android autocompletetextview

我自定义了自动填充文本视图,它在输入任何内容之前显示了建议。但是一旦我在textview上输入,它就不会过滤建议,为什么会发生这种情况..

public class CustomAutoCompleteTextView extends AutoCompleteTextView {

    /**
     * @param context
     */

    public CustomAutoCompleteTextView(Context context) {
        super(context);

    }

    public CustomAutoCompleteTextView(Context arg0, AttributeSet arg1) {
        super(arg0, arg1);
    }

    public CustomAutoCompleteTextView(Context arg0, AttributeSet arg1, int arg2) {
        super(arg0, arg1, arg2);
    }

    @Override
    public boolean enoughToFilter() {
        return true;
    }

    @Override
    protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
        super.onFocusChanged(focused, direction, previouslyFocusedRect);
        if (focused && getAdapter() != null) {
            performFiltering(getText(), 0);
            showDropDown();
        }
    }

}

0 个答案:

没有答案