Back to project page Weather.
The source code is released under:
Apache License
If you think the Android project Weather 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.volitic.weather; /* w w w . j a va 2 s .com*/ import android.content.Context; import android.database.Cursor; import android.widget.Filter; import android.widget.SimpleCursorAdapter; public class AutoCompleteCursorAdapter extends SimpleCursorAdapter { DatabaseHelper mDatabaseHelper; public AutoCompleteCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) { super(context, layout, c, from, to, flags); mDatabaseHelper = new DatabaseHelper(context); } @Override public CharSequence convertToString(Cursor cursor) { return super.convertToString(cursor); } @Override public Filter getFilter() { return new Filter() { @Override protected void publishResults(CharSequence constraint, FilterResults results) { changeCursor((Cursor)results.values); if (results.count > 0) { notifyDataSetChanged(); } else { notifyDataSetInvalidated(); } } @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults fr = new FilterResults(); Cursor cursor; if( constraint != null && constraint.length() > 0){ cursor = mDatabaseHelper.getLocationFilteredBy(constraint); } else { cursor = mDatabaseHelper.getAllLocations(); } fr.values = cursor; fr.count = cursor.getCount(); return fr; } }; } }