与谷歌播放一样,我希望搜索文本显示在搜索活动的操作栏的搜索栏中。目前它只是消失了。如何在另一个视图中显示结果时保留搜索栏和搜索文本
在主要活动中我有
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
// Associate searchable configuration with the SearchView
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView =
(SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setSearchableInfo(
searchManager.getSearchableInfo(getComponentName()));
return true;
}
在搜索活动中我有
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.booklisting);
// Get the Intent that started this activity and extract the string
handleIntent(getIntent());
//Intent intent = getIntent();
//String message = intent.getStringExtra("EXTRA_MESSAGE");
//execute_search(message);
}
protected void onNewIntent(Intent intent) {
setIntent(intent);
handleIntent(intent);
}
/**
* Handling intent data
*/
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
execute_search(query);
}
}