I have successfully implemented a custom SimpleCursorAdapter for an AutoCompleteTextView, which suggests entries from the database according to what has been entered into the box. However, I am getting the following non-fatal errors:
An exception occured during performFiltering()!
java.lang.NullPointerException
at com.stev.LondonTaxi.Route.runQuery(Route.java:456)
at com.stev.LondonTaxi.AutocompleteAdapter.runQueryOnBackgroundThread(AutocompleteAdapter.java:61)
Relevant extracts from my code are below - I wonder if anyone might be able to shed any light?
public class Route extends Activity implements View.OnClickListener,
AdapterView.OnItemClickListener, FilterQueryProvider {
from_adapt.setFilterQueryProvider(this);
public Cursor runQuery(CharSequence constraint) {
String filter = constraint.toString().toUpperCase() + "%'";
Cursor all_Cursor_filter = dbse.autocomplete_query(filter);
return all_Cursor_filter;
}
public class AutocompleteAdapter extends SimpleCursorAdapter implements Filterable {
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
if (getFilterQueryProvider() != null)
{ return getFilterQueryProvider().runQuery(constraint); }
return dbAdapt.autocomplete_query();
}
Steve
either constraint or dbse is null. not sure line 456 is which one.
but try to check constraint against null before toString call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With