完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/AutoCompleteTextView.html
AutoCompleteTextView
public class AutoCompleteTextView
extends EditText implements Filter.FilterListener
| java.lang.Object | ||||
| ↳ | android.view.View | |||
| ↳ | android.widget.TextView | |||
| ↳ | android.widget.EditText | |||
| ↳ | android.widget.AutoCompleteTextView | |||
An editable text view that shows completion suggestions automatically while the user is typing. The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.
一个可编辑的文本视图,在用户输入时自动显示补全建议提示。建议列表显示在一个下拉菜单中,用户可以从中选择一项来替换编辑框中的内容。
The drop down can be dismissed at any time by pressing the back key or, if no item is selected in the drop down, by pressing the enter/dpad center key.
通过按下back按钮,或者没有在下拉菜单中选择项而按下了enter/dpad的中间按键,都可以在任何时候关闭下拉菜单。
The list of suggestions is obtained from a data adapter and appears only after a given number of characters defined by the threshold.
建议列表的内容是从数据适配器中获取的,并且只在the threshold定义的指定字符数之后才出现。
The following code snippet shows how to create a text view which suggests various countries names while the user is typing:
下面的代码片段展示了如何创建一个文本视图,该视图在用户输入时显示不同的国家名称:
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" }; }
See the Text Fields guide.
请参考Text Fields指南。
摘要
嵌套类 | |
|---|---|
interface | AutoCompleteTextView.OnDismissListener Listener to respond to the AutoCompleteTextView's completion list being dismissed. |
interface | AutoCompleteTextView.Validator This interface is used to make sure that the text entered in this TextView complies to a certain format. |
XML属性 | |
|---|---|
android:completionHint | 设定下拉菜单中显示的提示。 |
android:completionHintView | 设定下拉菜单中显示的提示视图。 |
android:completionThreshold | 用户在下拉菜单里,显示完整建议之前,必须输入的字符数。 |
android:dropDownAnchor | 自动完成的下拉的参考视图。 |
android:dropDownHeight | 下拉菜单的高度。 |
android:dropDownHorizontalOffset | 下拉菜单水平偏移的像素数量。 |
android:dropDownSelector | 下拉菜单列表的选择器(Selector)样式。 |
android:dropDownVerticalOffset | 下拉菜单垂直偏移的像素数量。 |
android:dropDownWidth | 下拉菜单的宽度。 |
android:popupBackground | 弹出窗口的背景。 |
本文详细介绍Android中的AutoCompleteTextView组件,这是一种可编辑的文本视图,可在用户输入时自动提供补全建议。文章还介绍了如何使用代码创建一个带有国家名称建议的AutoCompleteTextView实例。
--- AutoCompleteTextView&spm=1001.2101.3001.5002&articleId=73221952&d=1&t=3&u=89d627b3961445b7bbbe78c1f74ec2ba)
603

被折叠的 条评论
为什么被折叠?



