我已經閱讀了Android官方網站,但仍然感到困惑。我可以問可搜索的活動和可搜索的界面兩種不同的活動嗎?我的理解是你新增了一個可搜索界面活動的意圖,然後將查詢傳遞給可搜索的活動。可搜索活動完成搜索並通過另一個意圖將適配器(通常情況下)返回給可搜索界面活動?搜索欄Android澄清
它是正確的嗎?
從網站上有這個片段:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the options menu from XML
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
// Assumes current activity is the searchable activity
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
return true;
}
是不是應該對搜索的界面活性?但爲什麼有兩條線以上的評論:
// Assumes current activity is the searchable activity
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
說// Assumes current activity is the searchable activity
?
請解釋。非常感謝。