Back to project page bodyguard.
The source code is released under:
GNU General Public License
If you think the Android project bodyguard listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.bodyguard; //from w ww.j a va2s .c o m import java.util.ArrayList; import android.content.Context; import android.widget.ArrayAdapter; import android.widget.Filter; import android.widget.Filterable; class PlacesAutoCompleteAdapter extends ArrayAdapter<String> implements Filterable { static ArrayList<String> resultList; public PlacesAutoCompleteAdapter(Context context, int textViewResourceId) { super(context, textViewResourceId); } @Override public int getCount() { return resultList.size(); } @Override public String getItem(int index) { return resultList.get(index); } @Override public Filter getFilter() { Filter filter = new Filter() { @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults filterResults = new FilterResults(); if (constraint != null) { // Retrieve the autocomplete results. PlaceAutoComplete places= new PlaceAutoComplete(); resultList = places.autocomplete(constraint.toString()); // Assign the data to the FilterResults filterResults.values = resultList; filterResults.count = resultList.size(); } return filterResults; } @Override protected void publishResults(CharSequence constraint, FilterResults results) { if (results != null && results.count > 0) { notifyDataSetChanged(); } else { notifyDataSetInvalidated(); } }}; return filter; } }