我们可以在 android 中加载一些特定文本的自动完成 TextView 吗?

Can we load Autocomplete TextView in android with some Specific text?

嗨,我是 android 技术的新手。我有一个自动完成的文本视图。它工作正常。

我的疑惑

我们可以在自动完成文本视图中加载一些默认文本吗?

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"
 };

当您想更新适配器时,清除这些值并更新适配器并调用 notifyDataSetChanged()。

来源:http://developer.android.com/reference/android/widget/AutoCompleteTextView.html

只需添加

android:text="some text" 

给你的Textviewxml

我能理解的是,您希望某些文本显示为 AutoCompleteTextView 中的默认文本。 为此,您可以简单地使用

 android:text="your text to appear as default"