I have an AutoCompleteTextView which shows a dropdown which is automatically updated while typing text. If the text matches a specific String, a Spinner control shows a certain category. This is done using a TextWatcher. (I used both the methods onTextChanged(...) and afterTextChanged(...). I have the same phenomenon with both methods.). This is working fine when entering the text manually. But this does not work when setting the text of the AutoCompleteTextView using setText(). The Text then comes from another activity that I started using startActivityForResult.
The value in the Spinner control is not changed. If removing a letter and adding it again, the Spinner control updates its value correctly. Does anyone know why? Does anyone know how to change this behavior?
I have an AutoCompleteTextView which shows a dropdown which is automatically updated while typing
Share
I found out the solution:
after returning from my 2nd Activity I have to call
requery()on my adapter’s cursor (((SimpleCursorAdapter)categorySpinnerAdapter).getCursor().requery();). Maybe in the meantime, people would not callrequery()anymore because it’s marked as deprecated, but I’ll take care of that later…(Can anyone explain this behavior? Is the cursor deactivated during
onPause()oronStop()?)But even that was not enough. My
SpinnerControldid not yet change its value.I also have to call
setAdapter()on theSpinnerControlto make it work again (spCategory.setAdapter(categorySpinnerAdapter);).(Does anybody know what’s going on here? should both opening the Cursor (or requerying) and attaching the Adapter be done in
onResume()oronStart()?)