有人能告诉我如何在“Multiline”MultiAutoCompleteTextView上显示建议.我去了API参考
Here.
我尝试了这个例子,自动完成工作得很好,除非我去下一行我不再看到建议了.
我有一个xml定义我的MultiAutoCompleteTextView,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<MultiAutoCompleteTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/html"
android:focusable="true"
android:gravity="top"
android:background="@null"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="5dp"
android:singleLine="false"
android:completionThreshold="1"
android:textSize="14dp"
android:scrollHorizontally="true"
android:focusableInTouchMode="true" />
我做这些建议的代码是这样的:(从参考文献中得到)
MultiAutoCompleteTextView editor = (MultiAutoCompleteTextView) LayoutInflater.from(getApplicationContext()).inflate(R.layout.editor, null);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
editor.setAdapter(adapter);
editor.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
因为我在MultiAutoCompleteTextView xml上将singleLine设置为false.当我按Enter进入下一行时,建议不会显示.
谁可以帮我这个事.有没有办法可以根据自己的喜好覆盖建议面板?还有办法定位面板吗?
最佳答案
android:inputType="textMultiLine"
“普通文本键盘,允许用户输入包含换行符(回车)的长字符串.”
http://developer.android.com/guide/topics/ui/controls/text.html