MultiAutoCompleteTextView 和 AutoCompleteTextView 之间的区别

发布于 2024-10-15 19:41:01 字数 96 浏览 6 评论 0原文

有人可以解释 MultiAutoCompleteTextViewAutoCompleteTextView 之间的区别吗?

Can someone explain the difference between MultiAutoCompleteTextView and AutoCompleteTextView?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

铃予 2024-10-22 19:41:01

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() );

and:

<MultiAutoCompleteTextView 
android:id="@+id/mac_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:completionThreshold="1"
/>

在这个例子中,建议出现在每个逗号之后。

AutocompleteTextView only offers suggestions about the whole sentence and MultiAutoCompleteTextView offers suggestions for every token in the sentence. You can specify what is the delimiter between tokens.

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() );

and:

<MultiAutoCompleteTextView 
android:id="@+id/mac_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:completionThreshold="1"
/>

with this example the suggestion comes after every comma.

何处潇湘 2024-10-22 19:41:01

使用 AutoCompleteTextView 或 MultiAutoCompleteTextView 之间的选择取决于是否应允许用户仅输入适配器提供的“一项”或“多项”。

例如,如果您正在编写一个电子邮件应用程序,并且您希望“收件人:”字段成为自动完成字段,从地址簿中提取匹配项,那么您很可能希望允许用户为一条消息选择多个收件人,并使该字段成为 MultiAutoCompleteTextView。

另一方面,在同一示例电子邮件应用程序中的“发件人:”字段中,您只需强制用户从其配置的电子邮件帐户中进行一次选择。因此 AutoCompleteTextView 在这里比较合适。

The choice between using the AutoCompleteTextView or the MultiAutoCompleteTextView comes down to whether or not the user should be allowed to input only "one item" as provided by the adapter, or "multiple items."

So for example, if you were writing an email app, and you wanted the "To:" field to be an autocomplete field, pulling matches from an address book, chances are you want to allow the user to pick multiple recipients for a message, and would make this field a MultiAutoCompleteTextView.

On the other hand, the "From:" field in the same example email app, you would need to enforce only a single selection by the user from their configured email accounts. And so an AutoCompleteTextView would be appropriate here.

萌无敌 2024-10-22 19:41:01

AutoCompleteTextView 和 MultiAutoCompleteTextView 的区别

AutoCompleteTextView 与 MultiAutoCompleteTextView

AutocompleteTextView 仅提供有关整个句子的建议 MultiAutoCompleteTextView 提供有关以下内容的建议句子中的每个标记。您可以指定标记之间的分隔符。

AutoCompleteTextView 用于选择单个项目 MultiAutoCompleteTextView 用于通过在项目之间使用分隔符(例如逗号)来选择多个项目。

在电子邮件应用程序示例中的“发件人:”字段中,您只需要强制用户从其配置的电子邮件帐户中进行一次选择。如果您正在编写一个电子邮件应用程序,并且希望“收件人:”字段成为自动完成字段,从地址簿中获取匹配项,那么您可能希望允许用户为一条消息选择多个收件人,并且会将该字段设置为MultiAutoCompleteTextView

Difference between AutoCompleteTextView and MultiAutoCompleteTextView

AutoCompleteTextView Vs MultiAutoCompleteTextView

AutocompleteTextView only offers suggestions about the whole sentence MultiAutoCompleteTextView offers suggestions for every token in the sentence. You can specify what is the delimiter between tokens.

AutoCompleteTextView is used for selecting single Item MultiAutoCompleteTextView is used for for selecting multiple Items by using a delimiter(such as comma) in betwwen them.

the “From:” field in example of email app, you would need to enforce only a single selection by the user from their configured email accounts. If you were writing an email app, and you wanted the “To:” field to be an autocomplete field, getting matches from an address book, chances you want to allow the user to pick multiple recipients for a message, and would make this field a MultiAutoCompleteTextView

心舞飞扬 2024-10-22 19:41:01
  • AutocompleteTextView 仅提供有关整体的建议
    句子
  • MultiAutoCompleteTextView 为中的每个标记提供建议
    句子。

您可以指定标记之间的分隔符,也可以设置第一个或任意一个。 Android 中使用 setThreshold()MultiAutoCompeleteTextView 控件的字符数。

  • AutocompleteTextView only offers suggestions about the whole
    sentence
  • MultiAutoCompleteTextView offers suggestions for every token in the
    sentence.

You can specify what is the delimiter between tokens also set the first or any no. of characters using setThreshold() with MultiAutoCompeleteTextView control in Android.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文