有人可以解释之间的差异MultiAutoCompleteTextView和 AutoCompleteTextView?
user-interface android autocompletetextview multiautocompletetextview
MultiAutoCompleteTextView当我输入几个字母时,我正在做一个简单的程序来提示常用词.
码:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this,
android.R.layout.simple_dropdown_item_1line,
ary);
MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.editText);
textView.setAdapter(adapter);
textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
private String[] ary = new String[] {
"abc",
"abcd",
"abcde",
"abcdef",
"abcdefg",
"hij",
"hijk",
"hijkl",
"hijklm",
"hijklmn",
};
Run Code Online (Sandbox Code Playgroud)
现在,当我输入'a'并选择"abcd"但结果变为"abcd"时.如何用空格替换逗号?
谢谢!
我已经在Gmail收据字段中搜索了一种具有类似外观的方法,该字段允许以非常酷的方式自动填充项目:

构建在Android框架中并负责此类的类称为" MultiAutoCompleteTextView ".
MultiAutoCompleteTextView是非常基础的,但它没有足够的样本,教程和库来了解如何在Gmail和类似的东西上自定义它.
我想知道如何自定义它来处理任何类型的数据,并且我将完全控制它(例如添加,删除和获取它已自动完成的项目).
我找到了下一步实现它的方法:
我决定使用#3(谷歌的芯片库).
目前获取Google图书馆使用的联系人列表的代码:
public List<RecipientEntry> doQuery() {
final Cursor cursor = mContentResolver.query(mQuery.getContentUri(), mQuery.getProjection(), null, null, null);
final LinkedHashMap<Long, List<RecipientEntry>> entryMap = new LinkedHashMap<Long, List<RecipientEntry>>();
final List<RecipientEntry> nonAggregatedEntries = new ArrayList<RecipientEntry>();
final Set<String> existingDestinations = new HashSet<String>();
while (cursor.moveToNext())
putOneEntry(new TemporaryEntry(cursor, false /* isGalContact */), true, entryMap, nonAggregatedEntries,
existingDestinations);
cursor.close();
final List<RecipientEntry> entries = new ArrayList<RecipientEntry>();
{
for (final …Run Code Online (Sandbox Code Playgroud) android autocomplete android-edittext multiautocompletetextview
我正在创建一个具有"To"字段的应用程序,就像Facebook应用程序的"新消息"功能一样.
从下拉列表中选择一个项目后,我创建了一个imagespan并将其添加到MultiAutoCompleteTextView.我已经习惯SpaceTokenizer了这个观点.问题是,当我点击退格键时,光标首先移动到空白区域(即空格Tokenizer),然后当我再次点击退格键时,整个单词被删除....我想删除我的整个单词第一次点击退格就像facebook app一样...
这是我的代码 SpaceTokenizer
multiContentText.setTokenizer(new Tokenizer(){
public int findTokenStart(CharSequence text, int cursor) {
int i = cursor;
if(i>0){
Log.d("textchar ",""+text.charAt(i - 1));
}
while (i > 0 && text.charAt(i - 1) != ' ') {
i--;
}
while (i < cursor && text.charAt(i) == ' ' || text.charAt(i - 1) == '\n') {
i++;
}
return i;
}
public int findTokenEnd(CharSequence text, int cursor) {
int i = cursor;
int len = text.length(); …Run Code Online (Sandbox Code Playgroud) android android-layout android-edittext multiautocompletetextview
我需要实现一个用户可以输入任何内容的编辑文本,但是当他们键入以"@"开头的新单词时,自动完成应该开始显示潜在用户.
我了解如何使用AutoCompleteTextView函数进行过滤.但是我不知道如何从'@'符号后面的最后一个单词中捕获字符(忽略之前的任何单词).
因此,当从AutoCompleteTextView列表中选择用户时,它应该用'@'替换该单词,例如.
"这是@steve的消息"
当用户点击列表中的"Steve"时,文本应替换为:
"这是给史蒂夫的信息"
我还需要以可以发送到服务器的形式获取字符串.即从上面的例子我需要发送字符串:
"这是[用户名:steve@bloggs.com,id:44]的消息."
我查看了https://github.com/splitwise/TokenAutoComplete
这似乎很适合在列表中键入电子邮件,但我不知道如何满足我的需求.请记住,我需要支持多个/重复提及:
例如
"这是一个消息,史蒂夫和鲍勃.这是消息中的第二句鲍勃 "
如果有人知道或做过这样的事情,我会非常感激!
android autocompletetextview multiautocompletetextview tokenautocomplete
似乎没有办法在Android中使用autocompletetextview和multiautocompletetextview启用自动更正.
我已经尝试了一些潜在的解决方法,但它们都没有工作(即使用XML文件中的各种输入选项).
有没有人能够在Autocompletetextview或Multiautocompletetextview上成功启用自动更正,并且仍然可以作为适配器提供建议列表?非常感谢!
我正在尝试MultiAutoCompleteTextView从用户那里获取文本并以类似气泡的格式显示它们,但我得到:android 中的宽度和高度必须 > 0
final MultiAutoCompleteTextView tags = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView1);
String[] TAGS = getResources().getStringArray(R.array.countries);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, TAGS);
tags.setAdapter(adapter);
tags.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
tags.setThreshold(1);
String contactName = tags.getText().toString();
final SpannableStringBuilder sb = new SpannableStringBuilder();
TextView tv = createContactTextView(contactName);
BitmapDrawable bd = (BitmapDrawable) convertViewToDrawable(tv);
bd.setBounds(0, 0, bd.getIntrinsicWidth(), bd.getIntrinsicHeight());
sb.append(contactName + ",");
sb.setSpan(new ImageSpan(bd), sb.length() - (contactName.length() + 1), sb.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Toast.makeText(getApplicationContext(),sb,Toast.LENGTH_SHORT).show();
}
public TextView createContactTextView(String text){
//creating textview dynamically
TextView tv = new TextView(this);
tv.setText(text);
tv.setTextSize(20); …Run Code Online (Sandbox Code Playgroud)