Pan*_*mar 61 user-interface android autocompletetextview multiautocompletetextview
有人可以解释之间的差异MultiAutoCompleteTextView和 AutoCompleteTextView?
Eri*_*ric 88
AutocompleteTextView只提供有关整个句子的MultiAutoCompleteTextView建议,并为句子中的每个标记提供建议.您可以指定令牌之间的分隔符.
String[] words=new String[] {
"word1", "word2", "word3", "word4", "word5"
};
MultiAutoCompleteTextView macTv = (MultiAutoCompleteTextView) this.findViewById(R.id.mac_tv);
ArrayAdapter<String> aaStr = new ArrayAdapter<String>(this,android.R.layout.dropdown_item,words);
macTv.setAdapter(aaStr);
macTv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer() );
Run Code Online (Sandbox Code Playgroud)
和:
<MultiAutoCompleteTextView
android:id="@+id/mac_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:completionThreshold="1"
/>
Run Code Online (Sandbox Code Playgroud)
在这个例子中,建议出现在每个逗号之后.
d60*_*402 69
使用AutoCompleteTextView或MultiAutoCompleteTextView之间的选择归结为是否应允许用户仅输入适配器提供的"一个项目"或"多个项目".
例如,如果您正在编写电子邮件应用程序,并且希望"收件人:"字段为自动填充字段,从地址簿中提取匹配项,则您可能希望允许用户为邮件选择多个收件人,并将使该字段成为MultiAutoCompleteTextView.
另一方面,在同一示例电子邮件应用程序中的"发件人:"字段中,您需要仅由用户从其配置的电子邮件帐户强制执行单个选择.所以AutoCompleteTextView在这里是合适的.
| 归档时间: |
|
| 查看次数: |
27439 次 |
| 最近记录: |