Hello, I am trying to use a SimpleAdapter to populate my AutoCompleteTextView. I observe that the Filter runs after the third keystroke as specified in my layout, and "suggestion_list" is being populated with at least five elements. After the filter runs, the completionHint drops down from the AutoCompleteTextView, but the there are no rows underneath (which should contain suggestions).
The underlying datastore is an ArrayList of HashMaps. The HashMap key to the value desired in the suggestion rows is "vernacular_name". Since I have specified this in the super() SimpleAdapter constructor, I assume that it should be calling setViewText with the correct arguments behind the scenes. Can anyone see what is wrong with this code, and why the Views corresponding to suggestions are absent from the AutoCompleteTextView dropdown? Thanks, Karl public class VernacularAutoComplete extends Activity { final static String TAG = "VernacularAutoComplete"; ArrayList<HashMap<String, String>> suggestion_list = new ArrayList<HashMap<String, String>>(); @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); this.setContentView(R.layout.autocomplete); SuggestionListAdapter autocomplete_adapter = new SuggestionListAdapter( this); AutoCompleteTextView textView = (AutoCompleteTextView) findViewById (R.id.userText); textView.setAdapter(autocomplete_adapter); } // XXX compiler bug in javac 1.5.0_07-164, we need to implement Filterable // to make compilation work public class SuggestionListAdapter extends SimpleAdapter implements Filterable { VernacularFilter vernacular_filter = new VernacularFilter(); public SuggestionListAdapter(Context context) { super(context, suggestion_list, android.R.layout.simple_list_item_1, new String[] { "vernacular_name" }, new int[] { android.R.id.text1 }); } class VernacularFilter extends Filter { @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults f = new FilterResults(); if (constraint != null) { // Log.d(TAG, "Running filter..."); ItisMirrorResponseParser imrp = new ItisMirrorResponseParser( (String) constraint); ArrayList<HashMap<String, String>> filter_result = imrp .parse(); f.values = filter_result; f.count = filter_result.size(); } return f; } @Override protected void publishResults(CharSequence constraint, FilterResults results) { VernacularAutoComplete.this.suggestion_list = (ArrayList<HashMap<String, String>>) results.values; SuggestionListAdapter.this.notifyDataSetChanged(); } } @Override public Filter getFilter() { return vernacular_filter; } } } ~~ autocomplete.xml ~~ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" > <AutoCompleteTextView android:id="@+id/userText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:completionThreshold="3" android:completionHint="Type a name..." > </AutoCompleteTextView> </LinearLayout> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---