2012-02-03 49 views
1

還是挺新的android系統(包括圖像)如何創建一個文本字段與Android歷史記錄?

我得克隆一個iphone應用程序。即時通訊有問題,首先要弄清楚接近如何克隆這個元素的最佳方式:

enter image description here

它是一個文本框,您可以鍵入字符的數量有限。 當你按下它時,列表應該顯示你輸入的最後五個元素(非自動完成),以便當你點擊它們時,它們被輸入到文本框中。

你會如何處理這個問題?哪個班最好的辦法是延長(我知道存儲可以通過共享偏好來完成)

感謝

+0

我目前的想法是,我可以通過共享首選項獲取歷史記錄,然後將其加載到適配器並將其連接到AutoCompleteTextView ..然後挑戰是以某種方式將閾值設置爲0(或以其他方式實現),以便所有答案是一旦有焦點設置 – AndroidGecko 2012-02-06 09:22:03

+0

這是有用的http://stackoverflow.com/questions/2126717/android-autocompletetextview-show-suggestions-when-no-text-entered – AndroidGecko 2012-02-06 09:29:20

回答

0

創建AutoCompleteTextView就像在這個例子中

stackoverflow.com/questions/2126717/

店歷史SharedPreferences

0

做到這一點:

AutoCompleteTextView textView = (AutoCompleteTextView)findViewById(R.id.autocomplete_country); 
// Get the string array 
String[] countries = getResources().getStringArray(R.array.countries_array); 
// Create the adapter and set it to the AutoCompleteTextView 
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, countries); 

textView.setAdapter(adapter);