0

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?

mseo
  • 3,881
  • 3
  • 22
  • 26

2 Answers2

3

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.

coyer
  • 4,122
  • 3
  • 28
  • 35
  • This holds true until today. It works by calling `ArrayAdapter#remove(Object)` followed by `ArrayAdapter#notifyDataSetChanged`. – Murat Karagöz Oct 01 '20 at 13:00
2

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.

Saad Farooq
  • 13,172
  • 10
  • 68
  • 94
  • well ... I asked this one year ago. I'm not even sure which project I used this in. Nevertheless, thank you for your answer. At least I upvoted it, because in general your right. – mseo Jan 10 '12 at 18:51
  • Haha... yeah I noticed the date but I figured that this question came up early in my search so I thought it might help others if there was an answer listed. Cheers. – Saad Farooq Jan 11 '12 at 05:08