2014-04-11 34 views
1

我的AutoCompleteTexView不會更新輸入的特定字符序列的視圖,它在其他時間更新視圖,但在AutoCompleteTexView中輸入「ca」它不更新視圖,列表和數據已更新並且正在設置。但是視圖沒有得到更新,對於所有其他序列,視圖更新了適當的結果。AutoCompleteTexView不改變下拉列表的視圖

final AutoCompleteArrayListAdapter mAdapter = new AutoCompleteArrayListAdapter(this, R.layout.spinner_item, oList); 
mAutoCompleteTextView.setAdapter(mAdapter); 
mAutoCompleteTextView.addTextChangedListener(new TextWatcher() { 

       @Override 
       public void onTextChanged(CharSequence s, int start, int before, int count) { 
        mAdapter.getFilter().filter(s);     
       } 

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

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

編輯:已解決問題。

通過將「1」的閾值設置爲「2」來解決此問題。

+0

這意味着,你oList沒有任何項目與「CA」。 –

+0

@Zohra:說我們正在尋找的國家,如果我輸入「CA」,我會得到CA {ex。加拿大},但該視圖未更新。如果我輸入「CAN」,我將得到加拿大下降,只有特定的字符序列「CA」的問題 –

+0

請發佈R.layout.spinner_item。 –

回答

0

嘗試設置的閾值的AutoCompleteTexView

mAutoCompleteTextView.setThreshold(1); 

或在佈局文件中定義它:

<AutoCompleteTextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:completionThreshold="1"/> 
+0

它被設置爲1,問題在我設置爲2後解決。 –