【问题标题】:Customized the Suggestion List of AutoComplete Text View自定义自动完成文本视图的建议列表
【发布时间】:2011-12-13 10:29:58
【问题描述】:

这是我的 AutoCompleteTextView 的代码:

    String[] countries = getResources().getStringArray(R.array.countries_array);
    final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.item_list ,countries);
    textView = (AutoCompleteTextView) dialog.findViewById(R.id.autoCompleteTextView1);
    adapter.setNotifyOnChange(true);
          textView.setAdapter(adapter);

这是 item_list :

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textSize="16sp"
android:textColor="#000"
 android:drawableRight="@drawable/arrow">

这是输出:

我想改变这种弹出式的建议框,并想在 AutoCompleteTextView 的下方显示建议列表 ..类似这样:(请忽略苹果设计,它只是结果出现的位置)

我该怎么做..请建议。 谢谢。!!

【问题讨论】:

标签: android android-layout autocomplete customization


【解决方案1】:

在您的布局中使用android:dropDownAnchorandroid:dropDownHorizontalOffsetandroid:dropDownVerticalOffset 和其他AutoCompleteTextView。见AutocompleteTextView

【讨论】:

    【解决方案2】:

    我在 AutoCompleteTextView 下方使用了一个 ListView。我将自定义适配器添加到 ListView 和 AutoCompleteTextView。我将 AutoCompleteTextView 下拉菜单的高度和宽度设置为 0:

    myListView.setAdapter(myCustomAdapter);
    myAutoComplete.setAdapter(myCustomAdapter);
    myAutoComplete.setDropDownHeight(0);
    myAutoComplete.setDropDownWidth(0);
    

    由于列表视图也附加到同一个适配器,它会在您更新自动完成时得到更新。

    【讨论】:

    【解决方案3】:

    你需要 QSB(快速搜索框)。 参考这个http://developer.android.com/resources/articles/qsb.html

    它需要一个 ContentProvider 来填充 QSB 数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-17
      • 1970-01-01
      相关资源
      最近更新 更多