本文整理了Java中android.view.MenuItem.collapseActionView()
方法的一些代码示例,展示了MenuItem.collapseActionView()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.collapseActionView()
方法的具体详情如下:
包路径:android.view.MenuItem
类名称:MenuItem
方法名:collapseActionView
暂无
代码示例来源:origin: k9mail/k-9
@Override
public boolean onQueryTextSubmit(String query) {
folderMenuItem.collapseActionView();
return true;
}
代码示例来源:origin: k9mail/k-9
@Override
public boolean onQueryTextSubmit(String query) {
folderMenuItem.collapseActionView();
actionBar.setTitle(R.string.filter_folders_action);
return true;
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
@Override
public void onGlobalLayout() {
int currentHeight = mView.getHeight();
if (currentHeight < mLastHeightOfContainer) { // 软键盘打开
if (mHeightOfVisibility == 0) {
mHeightOfVisibility = currentHeight;
}
isKeyboardOpen = true;
} else if (currentHeight > mLastHeightOfContainer && mLastHeightOfContainer != 0) { // 软键盘关闭
isKeyboardOpen = false;
// 隐藏搜索框
if (shouldExitSearchView) {
searchItem.collapseActionView();
}
}
mLastHeightOfContainer = currentHeight;
}
}
代码示例来源:origin: stackoverflow.com
import android.support.v7.widget.SearchView; // not the default !
@Override
public boolean onCreateOptionsMenu( Menu menu) {
getMenuInflater().inflate( R.menu.main, menu);
MenuItem myActionMenuItem = menu.findItem( R.id.action_search);
searchView = (SearchView) myActionMenuItem.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// Toast like print
UserFeedback.show( "SearchOnQueryTextSubmit: " + query);
if( ! searchView.isIconified()) {
searchView.setIconified(true);
}
myActionMenuItem.collapseActionView();
return false;
}
@Override
public boolean onQueryTextChange(String s) {
// UserFeedback.show( "SearchOnQueryTextChanged: " + s);
return false;
}
});
return true;
}
代码示例来源:origin: stackoverflow.com
final MenuItem searchMenuItem = optionsMenu.findItem(R.id.search);
final SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean queryTextFocused) {
if(!queryTextFocused) {
searchMenuItem.collapseActionView();
searchView.setQuery("", false);
}
}
});
代码示例来源:origin: robolectric/robolectric
@Test
public void collapseActionView_shouldReturnFalseIfActionViewIsNull() throws Exception {
item.setActionView(null);
assertThat(item.collapseActionView()).isFalse();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void collapseActionView_shouldInvokeListener() throws Exception {
item.setActionView(new View(ApplicationProvider.getApplicationContext()));
listener.expanded = true;
item.collapseActionView();
assertThat(listener.expanded).isFalse();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void collapseActionView_shouldSetExpandedFalse() throws Exception {
item.setActionView(new View(ApplicationProvider.getApplicationContext()));
item.expandActionView();
assertThat(item.collapseActionView()).isTrue();
assertThat(item.isActionViewExpanded()).isFalse();
}
代码示例来源:origin: stackoverflow.com
MenuItem menuSearch = menu.findItem(R.id.itemSearch);
SearchView searchView = (SearchView) menuSearch.getActionView();
//Don't use next line
//searchView.onActionViewCollapsed();
menuSearch.collapseActionView();
代码示例来源:origin: ukanth/afwall
@Override
public boolean onSearchRequested() {
MenuItem menuItem = mainMenu.findItem(R.id.menu_search); // R.string.search is the id of the searchview
if (menuItem != null) {
if (menuItem.isActionViewExpanded()) {
menuItem.collapseActionView();
} else {
menuItem.expandActionView();
search(menuItem);
}
}
return super.onSearchRequested();
}
代码示例来源:origin: grzegorznittner/chanu
@Override
public void closeSearch() {
if (searchMenuItem != null)
searchMenuItem.collapseActionView();
}
代码示例来源:origin: grzegorznittner/chanu
@Override
public void closeSearch() {
if (DEBUG) Log.i(TAG, "closeSearch /" + boardCode + "/" + threadNo + " q=" + query);
if (searchMenuItem != null)
searchMenuItem.collapseActionView();
}
代码示例来源:origin: adrianchifor/Swiftnotes
/**
* If back button pressed while search is active -> collapse view and end search mode
*/
@Override
public void onBackPressed() {
if (searchActive && searchMenu != null) {
searchMenu.collapseActionView();
return;
}
super.onBackPressed();
}
代码示例来源:origin: tangqi92/BuildingBlocks
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
if (searchMenuItem != null) {
searchMenuItem.collapseActionView();
}// end if
if (searchView != null) {
searchView.onActionViewCollapsed();
}// end if
}// end if
}
});
代码示例来源:origin: rsiebert/TVHClient
@Override
public boolean onSuggestionClick(int position) {
searchMenuItem.collapseActionView();
// Set the search query and return true so that the onQueryTextSubmit
// is called. This is required to pass additional data to the search activity
Cursor cursor = (Cursor) searchView.getSuggestionsAdapter().getItem(position);
String suggestion = cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1));
searchView.setQuery(suggestion, true);
return true;
}
代码示例来源:origin: stackoverflow.com
final MenuItem searchMenuItem = optionsMenu.findItem(R.id.search);
final SearchView searchView =
(SearchView) searchMenuItem.getActionView();
searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean queryTextFocused) {
if(!queryTextFocused) {
searchMenuItem.collapseActionView();
searchView.setQuery("", false);
}
}
});
代码示例来源:origin: cbeyls/fosdem-companion-android
@Override
protected void onStop() {
if ((searchMenuItem != null) && searchMenuItem.isActionViewExpanded()) {
searchMenuItem.collapseActionView();
}
super.onStop();
}
代码示例来源:origin: adityak368/Android-FileBrowser-FilePicker
private void closeSearchView() {
if (mSearchView.isShown()) {
mSearchView.setQuery("", false);
mSearchMenuItem.collapseActionView();
mSearchView.setIconified(true);
}
}
}
代码示例来源:origin: adityak368/Android-FileBrowser-FilePicker
private void closeSearchView() {
if (mSearchView.isShown()) {
mSearchView.setQuery("", false);
mSearchMenuItem.collapseActionView();
mSearchView.setIconified(true);
}
}
}
代码示例来源:origin: zulip/zulip-android
@Override
public boolean onQueryTextSubmit(String s) {
if (narrowedList != null) {
onNarrow(new NarrowFilterSearch(s, narrowedList.filter));
} else {
onNarrow(new NarrowFilterSearch(s, null));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
mSearchMenuItem.collapseActionView();
}
return true;
}
内容来源于网络,如有侵权,请联系作者删除!