本文整理匯總了Java中android.support.v7.widget.SearchView.setIconified方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchView.setIconified方法的具體用法?Java SearchView.setIconified怎麽用?Java SearchView.setIconified使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.setIconified方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search_view, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
mSearchView.setQueryHint("輸入歌曲名查找");
mSearchView.onActionViewExpanded();// 當展開無輸入內容的時候,沒有關閉的圖標
mSearchView.setIconified(true);//設置searchView處於展開狀態
// searchView.setSubmitButtonEnabled(true);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
//提交按鈕的點擊事件
Toast.makeText(SearchViewActivity.this, query, Toast.LENGTH_SHORT).show();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
//當輸入框內容改變的時候回調
// Log.i(TAG,"內容: " + newText);
quertMusic(newText);
return true;
}
});
mSearchAutoComplete = (SearchView.SearchAutoComplete) mSearchView.findViewById(R.id.search_src_text);
//設置輸入框內容文字和提示文字的顏色
mSearchAutoComplete.setHintTextColor(getResources().getColor(android.R.color.white));
mSearchAutoComplete.setTextColor(getResources().getColor(android.R.color.white));
return super.onCreateOptionsMenu(menu);
}
示例2: onPrepareOptionsMenu
import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
searchItem = menu.findItem(R.id.search);
searchItem.setOnActionExpandListener(new SearchViewExpandListener(menu));
searchView = (SearchView) searchItem.getActionView();
searchView.setIconified(false);
onQueryTextListener = new MuteableSearchViewOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(final String query) {
getFragment().onSearchQuerySubmitted(query);
return false;
}
@Override
public boolean onQueryTextChange(final String query) {
getFragment().onSearchQueryChanged(query);
return false;
}
});
searchView.setOnQueryTextListener(onQueryTextListener);
searchView.setOnCloseListener(() -> {
getFragment().onSearchClosed();
return false;
});
getFragment().onOptionsMenuPrepared();
return super.onPrepareOptionsMenu(menu);
}
示例3: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_search, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
mSearchView = (SearchView) menu.findItem(R.id.search).getActionView();
mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
//展開searchview
mSearchView.setIconified(false);
//顯示默認框內標簽
mSearchView.setIconifiedByDefault(true);
mToolbar.setTitle("");
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
intent.putExtra("q", query);
UIUtils.startActivity(intent);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
return true;
}
示例4: initViews
import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public void initViews(View view) {
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
((SearchActivity)(getActivity())).setSupportActionBar(toolbar);
((SearchActivity)(getActivity())).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
searchView = (SearchView) view.findViewById(R.id.searchView);
searchView.setIconified(false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
progressBar = (ContentLoadingProgressBar) view.findViewById(R.id.progressBar);
}
示例5: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
MenuItem item = menu.findItem(R.id.action_search);
searchView = (SearchView) item.getActionView();
if (searchView != null) {
searchView.setQueryHint(getResources().getString(R.string.query_hint));
searchView.setIconified(true);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(final String query) {
System.out.println("on search submit: " + query);
Thread searchThread = new Thread() {
public void run() {
result.needsClear();
result.downloading();
List<Crate> crates = Networking.searchCrate(query, 1);
for (Crate crate : crates) {
result.onResult(crate);
}
searchView.post(() -> searchView.clearFocus());
}
};
searchThread.start();
MainActivity.result.onResult(new Crate());
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText.length() > 0) {
if (summarySearchPager.getCurrentItem() != 1) {
summarySearchPager.setCurrentItem(1, true);
}
}
return false;
}
});
searchView.setOnCloseListener(() -> {
System.out.println("on search close");
summarySearchPager.setCurrentItem(0, true);
return false;
});
}
return true;
}