我有一台MultiAutoCompleteTextView。当我输入"Sal“时,它会提示"Salami”,但当我在框中按下它时,会显示"Salami,“。
我怎么会喜欢这样呢?
我的代码:
无效的addAutoSuggest ()
{
myDB = this.openOrCreateDatabase(MY_DB_NAME, MODE_PRIVATE, null);
ArrayList<String> list = new ArrayList<String>();
Cursor cursor = this.myDB.query(MY_DB_TABLE, new String[] {"name"},null,null,null,null,null,null);
if (cursor.moveToFirst()) {
do {
String str= cursor.getString(0);
list.add(str);
}
while (cursor.moveToNext());
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
if (list!=null)
{
name.setAdapter( new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, list));
name.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
}
}发布于 2011-10-03 18:42:08
在MultiAutoCompleteTextView中,它总是需要分隔符,所以我认为你不能去掉它。但是您可以使用空格作为分隔符,而不是逗号,然后您可以修剪最后的字符串以供进一步使用。你可以在这里找到解决方案-
How to replace the comma with a space when I use the "MultiAutoCompleteTextView"
或者,如果您想继续使用',‘作为分隔符,那么您必须手动删除在MultiAutoCompleteTextView中获得的最后一个字符串中的最后一个逗号。
https://stackoverflow.com/questions/7633846
复制相似问题