(包括图像)如何在android中创建具有历史记录的文本字段?

时间:2012-02-03 16:05:08

标签: android listview textview android-edittext

仍然是android的新手

我必须克隆一个iphone应用程序。我在弄清楚如何克隆这个元素的最佳方法时遇到了问题:

enter image description here

它是一个文本框,您可以在其中键入有限数量的字符。 按下它时,列表应显示您输入的最后五个元素(不是自动完成),这样当您单击它们时,它们就会输入到文本框中。

你会怎么做?哪个类最适合扩展(我知道存储可以通过共享首选项完成)

由于

2 个答案:

答案 0 :(得分:0)

创建一个AutoCompleteTextView,就像在这个例子中一样

stackoverflow.com/questions/2126717 /

在SharedPreferences中存储历史记录

答案 1 :(得分: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);