小编cen*_*men的帖子

如何在“多行”MultiAutoCompleteTextView 上显示建议?

有人可以告诉我如何在“多行”MultiAutoCompleteTextView 上显示建议。我去了这里的 API 参考。

我试过那个例子,自动完成工作得很好,除非当我转到下一行时,我再也看不到建议了。

我有一个 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" />
Run Code Online (Sandbox Code Playgroud)

我提出建议的代码是这样的:(从参考资料中得到)

   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());
Run Code Online (Sandbox Code Playgroud)

因为我在 MultiAutoCompleteTextView xml 上将 singleLine 设置为 false。当我按 Enter 键转到下一行时,建议不会显示。

谁可以帮我这个事。有没有办法可以根据我的喜好覆盖建议面板?还有没有办法定位面板?

android

5
推荐指数
1
解决办法
1757
查看次数

标签 统计

android ×1