我正在尝试使用自定义数据集来使用SearchWidget操作栏功能。问题是当我在搜索栏中输入任何字符时,建议ui为空。从日志中我看到使用了ContentProvider。但是,我不会在“可搜索活动”中看到任何日志。
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
// TODO: Implement this to handle query requests from clients.
String query = uri.getLastPathSegment().toLowerCase();
Log.d("app", "AAAAAAAAAAAAA "+query);
String[] columnNames = {"_id", "Column1"};
MatrixCursor matrixCursor = new MatrixCursor(columnNames);
matrixCursor.addRow(new String[]{"1a", "r1v1"});
matrixCursor.addRow(new String[]{"2a", "r2v1"});
return matrixCursor;
//adapter.swapCursor(matrixCursor);
//throw new UnsupportedOperationException("Not yet implemented");
}
我的SearchableActivity有以下内容:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_searchable);
Log.d("app", "NNNNNNNNNNNNNN");
// Get the intent, verify the action and get the query
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
} else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
// Handle a suggestions click (because the suggestions all use ACTION_VIEW)
Uri data = intent.getData();
}
}
我想我错过了一些非常简单的步骤来连接一些点并显示结果。有人可以帮忙吗?