Ankit
Ankit

Reputation: 11

How to get autocomplete edittext as a SearchBar in android?

I've made a basic browser, and I want to use autocomplete edittext in my ActionBar(ToolBar).

I have read this--> https://developer.android.com/training/keyboard-input/style It says that I need an adapter that provides the keywords list for auto-completion, but I need it for prediction purposes. Using a text resource for prediction will make it static(limited).

I need it as our mobile browsers have, just type a keyword and it suggests you. It suggests you a word or a complete sentence.

like this screenshot:

enter image description here

please help me... Thank You :-)

Upvotes: 1

Views: 508

Answers (2)

Khanzada
Khanzada

Reputation: 15

use this:

<?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" />

Upvotes: 1

mohit
mohit

Reputation: 88

use 'AutoCompleteTextView' instead of normal EditText.

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

Upvotes: 1

Related Questions