<h3><span style="color: #000080;"><strong>What is AutoComplete Textview?</strong></span></h3>
<p>An <strong><span style="color: #008000;">editable</span></strong> text view that shows completion suggestions automatically while the user is typing. The list of suggestions is displayed in a drop-down menu from which the user can choose an item to replace the content of the edit box with.</p>
<p>Get <span style="color: #0000ff;"><strong>GITHUB</strong></span> code from <span style="color: #0000ff;"><a style="color: #0000ff;" href="https://github.com/arunk7839/AutoCompleteTextviewExp"><strong>Here</strong></a></span>.</p>
<p><span class="embed-youtube" style="text-align:center; display: block;"><amp-youtube data-videoid="DYEtvC7merk" data-param-rel="1" data-param-showsearch="0" data-param-showinfo="1" data-param-iv_load_policy="1" data-param-fs="1" data-param-hl="en-US" data-param-autohide="2" data-param-wmode="transparent" width="1200" height="675" layout="responsive"><a href="https://www.youtube.com/watch?v=DYEtvC7merk" placeholder><amp-img src="https://i.ytimg.com/vi/DYEtvC7merk/hqdefault.jpg" alt="YouTube Poster" layout="fill" object-fit="cover"><noscript><img src="https://i.ytimg.com/vi/DYEtvC7merk/hqdefault.jpg" loading="lazy" decoding="async" alt="YouTube Poster"></noscript></amp-img></a></amp-youtube></span></p>
<h3><strong><span style="color: #000080;">Creating New Project</span></strong></h3>
<ol>
<li>In Android Studio, go to <span style="color: #008000;"><strong>File </strong><strong>⇒</strong><strong> New Project</strong></span> and fill all the details required to create a new project. When it prompts to select a default activity, select <span style="color: #008000;"><strong>Blank Activity</strong></span> and proceed.</li>
<li>Open <span style="color: #008000;"><strong>activity_main.xml</strong></span> in which I have add one<strong><span style="color: #008000;"> AutoCompleteTextview</span></strong> with following basic properties.</li>
</ol>
<p><span style="color: #3366ff;"><strong>activity_main.xml</strong></span></p>
<!-- WP QUADS Content Ad Plugin v. 2.0.98.1 -->
<div class="quads-location quads-ad2" id="quads-ad2" style="float:none;margin:0px;">

</div>

<pre><strong><;?xml version="1.0" encoding="utf-8"?>;
<;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:layout_margin="10dp"
 tools:context="com.example.lenovo.autocompletetextview.MainActivity">;

 <;TextView
 android:id="@+id/tv_country_name"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_marginTop="10dp"
 android:text="Enter country name :"
 android:textColor="@color/colorPrimaryDark"
 android:textSize="20dp"
 android:textStyle="bold" />;

 <;AutoCompleteTextView
 android:id="@+id/ac_tv"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_below="@id/tv_country_name"
 android:layout_marginTop="5dp" />;

<;/RelativeLayout>;</strong>

</pre>
<p style="padding-left: 30px;">3. Now open <span style="color: #008000;"><strong>MainActivity.java</strong></span> and and add the below code. The following code snippet shows how to create a text view which suggests various countries names while the user is typing:</p>
<p><span style="color: #3366ff;"><strong>MainActivity.java<br />
</strong></span></p>
<pre><strong>package com.example.lenovo.autocompletetextview;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;


public class MainActivity extends AppCompatActivity {

 String[] country = {"Australia", "Albania", "Algeria", "Angola", "Belgium", "Bhutan", "Canada", "China", "India"};

 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);


 <span style="color: #008000;">//We can use any of the built_in android layout simple_list_item_1 and select_dialog_item</span>
 ArrayAdapter<;String>; adapter = new ArrayAdapter<;String>;(this, android.R.layout.simple_list_item_1, country);

 AutoCompleteTextView ac_tv = (AutoCompleteTextView) findViewById(R.id.ac_tv);

 <span style="color: #008000;">//Start character for search</span>
 ac_tv.setThreshold(1);

 <span style="color: #008000;">//Setting adapter</span>
 ac_tv.setAdapter(adapter);

 <span style="color: #008000;">//Setting textcolor after selection</span>
 ac_tv.setTextColor(Color.BLUE);
 }
}
</strong></pre>
<h5><span style="color: #0000ff;"><strong>Now if you run the app you can see the book list will look like this:</strong></span></h5>
<p><img class="wp-image-171 aligncenter" src="https://c1ctech.com/wp-content/uploads/2018/03/Screenshot_2018-03-06-18-07-441.png" alt="" width="443" height="738" /></p>
<p> ;</p>
<p> ;</p>
<p> ;</p>
<p> ;</p>


