I am using AutoComplete
widget. It works fine for two characters search but doesen't work for one character. I want to auto complete work even when user enters only one character.
For example when I enter "1" it should show all list start with "1". Now its showing suggestions list for 2 characters for example "12".
Code:
zip.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { String url = "xxxxxxxxxxxxxxxxxxxxxxx"; String from = "zip"; new GetAutoComplete(url, from).execute();// getting list } } }); ArrayAdapter<Integer> aa = new ArrayAdapter<Integer>( MyActivity.this, R.layout.list_item_of_zip, zip_codes); zip.setAdapter(aa); // zip = autocomplete widget and zip_codes = arrayList
Set your completionThreshold to 1.
<AutoCompleteTextView android:id="@+id/your_id" android:layout_width="200dp" android:layout_height="wrap_content" android:completionThreshold="1" />
Or to do it dynamically use mAutoCompleteTextView.setThreshold(1)
.
http://developer.android.com/reference/android/widget/AutoCompleteTextView.html
Makes the threshold as one so it starts from the first letter onwards. You can do that using:
mAutoCompleteTextView.setThreshold(1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With