I am facing a weird problem with AutoCompleteTextView. My code is as follows,
AutoCompleteTextView searchText = //findView...
private ArrayList<String> suggestions = null;
private ArrayAdapter<String> suggestionAdapter = null;
suggestionAdapter = new ArrayAdapter<String>(this, R.layout.list, suggestions);
searchText.setAdapter(suggestionAdapter);
And down the code, I am populating the arrayList in a for loop.
for (int i = 0; i < nl.getLength(); i++) {
Element suggestion = (Element)nl.item(i);
String name = suggestion.getAttribute("data");
suggestions.add(name);
}
This is not showing me the suggestions while I type into the text view.
However, when I add any strings to the arraylist outside the for loop (like, right after the loop), I am able to see the suggestions. Its been bugging me for the last two hours. Any suggestions would be appreciated.
And believe me I am typing one of the known text that I am populating in the for loop.
Thx! Rahul.