![AutoCompleteTextView AutoCompleteTextView](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsuDWxUVSORTfHIaGC4nfVXjumugeUTVss3WAuHuUs8UPwDU1zrDr-xfzEl0EjzwODrvK67pgE2pEQQiPQ4Y8k1MLkqC8Xu2PYuYSxr_BHP9reJkKZi6VacnzcKDvdEh0TGwBbhO9IpbLf/s400/AutoCompleteTextView.png)
It can be comapred with "Example of MultiAutoCompleteTextView".
main.xml
<?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:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<AutoCompleteTextView android:id="@+id/myautocomplete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:completionThreshold="1"
/>
</LinearLayout>
AndroidAutoCompleteTextView.java
package com.AndroidAutoCompleteTextView;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class AndroidAutoCompleteTextView extends Activity implements TextWatcher{
AutoCompleteTextView myAutoComplete;
String item[]={
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myAutoComplete = (AutoCompleteTextView)findViewById(R.id.myautocomplete);
myAutoComplete.addTextChangedListener(this);
myAutoComplete.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, item));
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
}
Thank you for reading this article Example of AutoCompleteTextView With URL https://x-tutorials.blogspot.com/2010/07/example-of-autocompletetextview.html. Also a time to read the other articles.
0 comments:
Write your comment for this article Example of AutoCompleteTextView above!