2016-12-27 29 views
-3

我正在開發一個小型字典應用程序使用Sqlite數據庫哪裏有兩列.. Word和Word定義..現在我怎麼填充AutoCompleteTextView因此,當用戶開始鍵入任何Word for搜索我可以根據他/她的第一個輸入的字母來顯示他/她所有來自單詞欄的單詞嗎?如何填充SQLite數據庫中的AutoCompleteTextView

+2

你到目前爲止嘗試了什麼?請張貼一些代碼。請參閱[如何提問](http://stackoverflow.com/help/how-to-ask) – MrLeeh

回答

1

你有沒有結帳docs,有一個關於如何在那裏使用AutoCompleteTextView的很好的例子。

public class CountriesActivity extends Activity { 
    protected void onCreate(Bundle icicle) { 
     super.onCreate(icicle); 
     setContentView(R.layout.countries); 

     ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 
      android.R.layout.simple_dropdown_item_1line, COUNTRIES); 
     AutoCompleteTextView textView = (AutoCompleteTextView) 
      findViewById(R.id.countries_list); 
     textView.setAdapter(adapter); 
    } 

    private static final String[] COUNTRIES = new String[] { 
     "Belgium", "France", "Italy", "Germany", "Spain" 
    }; 
} 

使用上面的例子,你只需要檢索你的單詞到數組中,並將它傳遞給適配器。

+0

如果我的答案解決了您的問題,請不要忘記標記我的答案爲正確的 – Isaac

相關問題