AutoCompleteTextView, ArrayAdapter and notifyDataSetChanged()
I'm using an AutoCompleteTextView with an ArrayAdapter which works like supposed.
The problem is, that I have to change the Array 开发者_开发百科with the Autocomplete-Values. Calling notifyDataSetChanged() doesn't help. No changes are shown.
Do you know something to get around this problem?
Do not modify the ArrayList
and call notifyDataSetChanged()
as it will have no effect on ArrayAdapters (implementation seems broken).
Use clear()
, add()
, insert()
, and remove()
directly on your ArrayAdapter
instead of those methods on your ArrayList
.
You need to add more details to the question but based on a guesstimate of you problem, I would say that there is some problem in the implementation.
notifyDataSetChanged()
informs the view to reload the data. If the data set up methods in the ArrayAdapter reference an unchanged data entity, notifyDataSetChanged()
will have not effect.
A custom adapter implementation that extends ArrayAdapter will generally have an internal data structure that is the source of data for the adapter and which will contain the AutoComplete values you require.
精彩评论