AutoComplete widget code...

In this android application we will use Auto Complete features.I mean, when user try to start typing a string in a AutoCompleteTextView field,it gives suggesion as per user input.For this we take some strings in our code.When the user input matches with one or more string the strings are shown accordingly.Then the user can type the full text or simply select the desired string from the list.In our code the selected string is shown in a TextView.
For this application we will take a XML layout containing a TextView and a AutoCompleteTextView.The XML code is:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/selection"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<AutoCompleteTextView android:id="@+id/edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:completionThreshold="3"/>
</LinearLayout>


Now we write the code to implement the AutoCompleteTextView widget.The strings in the array(items) are the suggestion that will pop up during user input.Now look at the code below:

package com.android.autocomplete;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.TextView;

public class AutoCom extends Activity implements TextWatcher{