【问题标题】:How to get autocomplete edittext as a SearchBar in android?如何在android中将自动完成edittext作为搜索栏?
【发布时间】:2019-04-23 10:06:33
【问题描述】:

我已经制作了一个基本的浏览器,我想在我的 ActionBar(ToolBar) 中使用自动完成编辑文本。

我读过这个--> https://developer.android.com/training/keyboard-input/style 它说我需要一个适配器来提供自动完成的关键字列表,但我需要它来进行预测。使用文本资源进行预测将使其成为静态(有限)。

我需要它,就像我们的移动浏览器一样,只需输入一个关键字,它就会向您推荐。它建议你一个单词或一个完整的句子。

喜欢这个截图:

请帮帮我...谢谢 :-)

【问题讨论】:

    标签: java android material-design searchbar


    【解决方案1】:

    使用“AutoCompleteTextView”而不是普通的 EditText。

    https://developer.android.com/training/keyboard-input/style

    【讨论】:

      【解决方案2】:

      使用这个:

      <?xml version="1.0" encoding="utf-8"?>
      <AutoCompleteTextView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/autocomplete_country"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" />
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-12-29
        • 1970-01-01
        • 1970-01-01
        • 2013-03-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-24
        相关资源
        最近更新 更多