【问题标题】:Search Suggestions In AndroidAndroid 中的搜索建议
【发布时间】:2013-08-26 10:36:26
【问题描述】:

我已经使用edittext 和listview 在android 中完成了搜索建议。

我真正需要的是在我的活动中,edittext 之后有很多按钮,当我在编辑文本中键入字母时,它将在列表视图中显示相应的搜索,但按钮将出现在该列表视图之后。

我的 xml 文件看起来像这样..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
 <!-- Editext for Search -->
<EditText android:id="@+id/inputSearch"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="Search products.."
    android:inputType="textVisiblePassword"/>

<!-- List View -->
<ListView
    android:id="@+id/list_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="after Edit Text"/>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Second Button"/>
</LinearLayout>

我得到的输出为

我需要的是我的建议列表,不应该在可搜索的编辑文本之后干扰背景中的任何按钮,任何帮助将不胜感激

【问题讨论】:

  • 我想你要找的是AutoCompleteTextView..

标签: android listview search


【解决方案1】:

将布局更改为::将按钮移到 listView 之前

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
 <!-- Editext for Search -->
<EditText android:id="@+id/inputSearch"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="Search products.."
    android:inputType="textVisiblePassword"/>

<Button android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="after Edit Text"/>

    <Button android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Second Button"/>

<!-- List View -->
<ListView
    android:id="@+id/list_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />


</LinearLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-10
    相关资源
    最近更新 更多