Hi Guys!
An AutoComplete TextView is an editable 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.
The drop down can be dismissed at any time by pressing the back key or, if no item is selected in the drop down, by pressing the enter/dpad center key.
FOr detail about the Auto Complete Text View please visit the android developer site AutoCompleteTextView.
Now lets start the coding about the auto text complete view . Here we are getting the item data in array from xml resource.And these array data stored in the adapter.
You can download the source code Auto Complete Text View
Cheers Guys!
An AutoComplete TextView is an editable 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.
The drop down can be dismissed at any time by pressing the back key or, if no item is selected in the drop down, by pressing the enter/dpad center key.
FOr detail about the Auto Complete Text View please visit the android developer site AutoCompleteTextView.
Now lets start the coding about the auto text complete view . Here we are getting the item data in array from xml resource.And these array data stored in the adapter.
res/value/myvalues.xml
- January
- February
- March
- April
- May
- June
- July
- August
- September
- October
- November
- December
activity_main.xml
MainActivity.java
package com.sunil.autocompletetext;
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 MainActivity extends Activity implements TextWatcher {
AutoCompleteTextView autoCompleteTextView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
autoCompleteTextView = (AutoCompleteTextView)findViewById(R.id.input);
String[] month = getResources().getStringArray(R.array.month);
autoCompleteTextView.addTextChangedListener(this);
autoCompleteTextView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, month));
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
}
}
You can download the source code Auto Complete Text View
Cheers Guys!
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :