AutoCompleteTextView Application

AutoCompleteTextView application is same like as google search. When you type in google textbox, it give some suggestion automatically. This application same as Google Search.

Step 1.

Create new application with any name from file menu option.
File → New Project → Application name → select API → Add Blank Activity → Activity Name → finish

Step 2.

In activity_main.xml layout file design your application.
Add following Controls:-

autocomplete textview

Step 3.

Import Package and write following coding in MainActivity.java class file

    
    import android.widget.ArrayAdapter;
    import android.widget.AutoCompleteTextView;
    import android.widget.TextView;

	public class MainActivity extends ActionBarActivity {

    AutoCompleteTextView at;
    String name[]={"Akhtar","Akash","Arshi","Akhtar","Manzar","Mandeep","Manpreet"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        at=(AutoCompleteTextView)findViewById(R.id.autoCompleteTextView);
        ArrayAdapter ad=new ArrayAdapter(this,android.R.layout.simple_List_item_1,name);
        at.setAdapter(ad);
    }

Step 4. Final Output

Finally run your application. Type any name in textbox field which you have set in string.

autocomplete textview
Advertisement here

Share this Page.