如何在AutoCompleteTextView中了解文本完成

时间:2014-09-12 07:36:35

标签: android textview autocompletetextview

我只想在AutoCompleteTextView中的Text Completion之后调用一个方法。不可能将方法放在afterTextChanged旁边,它是根据文本更改连续调用方法。我想在Text Completion上只调用一次该方法。我怎么能这样做..请帮忙......

1 个答案:

答案 0 :(得分:0)

试试这个:

private CustomAutoCompleteTextView mAutoFillTextView;
mAutoFillTextView.addTextChangedListener(new TextWatcher() {
    @Override
    public void onTextChanged(final CharSequence s, int start, int before, int count) {
        String string = s.toString().trim();
        if (mAutoFillTextView.getThreshold() <= string.length() && mAllowRequest) {
            Toast.makeText(getActivity(), "OK : " + string, Toast.LENGTH_LONG).show();
        } else if (string.equals("")) {
            Toast.makeText(getActivity(), "OK : " + string, Toast.LENGTH_LONG).show();
        }
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

    @Override
    public void afterTextChanged(Editable s) {}
});