2012-04-01 16 views
23

私はAutoCompleteウィジェットを使用しています。それは2文字の検索でうまく動作しますが、1文字に対しては機能しません。ユーザーが1文字しか入力しなくても自動完成したい1文字でも自動補完検索android

たとえば、「1」を入力すると、すべてのリスト開始が「1」で示されます。 これは2文字(例えば "12")のリストを表示します。

コード:

zip.setOnFocusChangeListener(new OnFocusChangeListener() { 

     @Override 
     public void onFocusChange(View v, boolean hasFocus) { 
      if (hasFocus) { 
       String url = "xxxxxxxxxxxxxxxxxxxxxxx"; 
       String from = "zip"; 
       new GetAutoComplete(url, from).execute();// getting list 

      } 
     } 
    }); 



ArrayAdapter<Integer> aa = new ArrayAdapter<Integer>(
       MyActivity.this, R.layout.list_item_of_zip, 
       zip_codes); 
      zip.setAdapter(aa); // zip = autocomplete widget and zip_codes = arrayList 
+0

コードバディを更新しました! – Sunny

+0

カウント0で何を意味するのか分かりませんが、そのようなことはありません。 – Sunny

答えて

7

一つとして、閾値がそう、それは以降の最初の文字から開始させます。 あなたはそれを使用してこれを行うことができます:

mAutoCompleteTextView.setThreshold(1); 
関連する問題