I am trying to filter out results that do not start with the text entered in the autocompletetextview textbox. The initial hashmap gets loaded via an asynctask that runs the in background once the program loads. Here is my performFilter code:
try{
// Note the clone - original list gets stripped
for(Iterator<Map.Entry<String, String>> it = dataToSearch.entrySet().iterator(); it.hasNext();)
{
Map.Entry<String, String> entry = it.next();
String lowercase = entry.getValue().toLowerCase();
if(lowercase.startsWith(constraint.toString().toLowerCase()))
searchMap.put(entry.getKey(), entry.getValue());
it.remove();
}
}catch (Exception e){
Log.d("HUS","EXCEPTION "+e);
}
FilterResults filterResults = new FilterResults();
filterResults.values = searchMap;
filterResults.count = searchMap.size();
My issue is that either all of the results from the initial hashmap show up or none of the results show up. What might I be doing wrong? The async task calls the adapter.notifyDatasetChanged when the initial hashmap changes but I still would think that the filter results would be based on what the text in the textview starts with. Any help is appreciated.