I have implemented a search widget as explained in android docs which works fine. I am trying to build a custom search suggestion using searchable configuration and content provider, the listview shows up quite alright, but it is empty - no text or icon. Here is a screenshot
here is my searchable.xml
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://ift.tt/nIICcg"
android:label="@string/app_name"
android:searchSuggestAuthority="com.example.makmessengerprototype.provider"
android:searchSuggestSelection="name_ LIKE ?"
android:searchSuggestIntentAction="android.intent.action.VIEW"
android:hint="@string/search_hint" >
</searchable>
And here is my query() in my content provider
@Override
public Cursor query(Uri uri, String[] columns, String selection, String[] selectionArgs, String sortOrder) {
SQLiteDatabase db = dbHelper.getWritableDatabase();
String query = uri.getLastPathSegment().toLowerCase();
String[] mselectionArgs = {"%"+query+"%"};
Log.d("Selection Args",mselectionArgs[0]);
Cursor cursor = db.query(DbHelper.SEARCH_TABLE, columns, selection, mselectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
if (cursor!=null) {
Log.d("Cursor Returned!", "");
return cursor;
}
else if (!cursor.moveToFirst()) {
//try another search method
Log.d("Cursor not Returned!","");
return null;
}
else {
return null;
}
}
Here is how am creating my search table
db.execSQL("CREATE TABLE " + SEARCH_TABLE + " (_id INTEGER PRIMARY KEY AUTOINCREMENT, name_ text, SUGGEST_COLUMN_TEXT_1 text, SUGGEST_COLUMN_TEXT_2, SUGGEST_COLUMN_ICON_1 text)");
Aucun commentaire:
Enregistrer un commentaire