我正在尝试实现搜索对话框,我无法显示活动中的搜索.
我在我的清单文件中定义了我的主要活动,此活动向用户显示他们必须选择的选项列表.其中一个选项是“搜索”选项.
android:name=".MenuListActivity"
android:label="@string/app_name">
我的搜索活动在我的清单文件中定义,如此.
android:launchMode="singleTop"
android:label="@string/app_name">
android:resource="@xml/searchable"/>
现在我的问题是当我从我的MenuListActivity调用onSearchRequested()时没有任何反应.
public void onItemClick(AdapterView> parent, View itemClicked, int position, long id) {
String strText = items[position];
if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_browse))) {
startActivity(new Intent(MenuListActivity.this, WSMobileActivity.class));
} else if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_search))) {
// If i call it like this it doesn't work, nothing happens
onSearchRequested();
} else if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_locator))) {
startActivity(new Intent(MenuListActivity.this, StoreLocatorActivity.class));
}
}
请帮忙,如何从我的MenuActivity调用搜索请求?