I use in my application an autocompletetextview field and would like to implement following functionality:
- There is an entry (the last one) in the adapter which should always contain of "user input:" + vartext. The vartext is the text typed by user in autocompletetextview field.
Is there any change listener for autocompletetextview?
I tried to use addTextChangedListener, TextWatcher and onTextChanged, but it seems to be called only once.
Did I do something wrong?! Here is my code:
- Code: Select all
public class HelloListView extends Activity
List<String> countryList = null;
AutoCompleteTextView textView = null;
ArrayAdapter adapter = null;
static String COUNTRIES = new String
"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
"Yemen", "Yugoslavia", "Zambia", "Zimbabwe", ""
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState)
countryList = Arrays.asList(COUNTRIES);
textView = (AutoCompleteTextView) findViewById(R.id.edit);
adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, countryList);
public void onTextChanged(CharSequence s, int start, int before, int count)
countryList.set(countryList.size()-1, "User input:" + textView.getText());
public void beforeTextChanged(CharSequence s, int start, int count,
public void afterTextChanged(Editable s)
I saw already [url]this topic[/url] but they suggest to clear adapter and to fill it again. It's not really thing I want to have.
Thank you in advance,