本文整理汇总了Java中android.widget.SearchView.setOnCloseListener方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setOnCloseListener方法的具体用法?Java SearchView.setOnCloseListener怎么用?Java SearchView.setOnCloseListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.setOnCloseListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu_context) {
getMenuInflater().inflate(R.menu.menu_principal, menu_context);
MenuItem searchItem = menu_context.findItem(R.id.action_search_main);
SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setOnQueryTextListener(mQueryTextListener);
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
ArrayList<Event> list_event = new ArrayList<Event>();
list_event = (ArrayList<Event>) new EventDao(getApplication().getApplicationContext()).getAll();
mAdapterTodosEventos.setData(list_event);
mAdapterTodosEventos.notifyDataSetChanged();
return false;
}
});
return true;
}
示例2: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_tab_detalhe_evento_programacao, menu);
MenuItem searchItem = menu.findItem(R.id.action_search_tab_detalhe_programacao);
SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setOnQueryTextListener(mQueryTextListenerTalk);
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
ArrayList<Talk> list_talk = new ArrayList<Talk>();
list_talk = (ArrayList<Talk>) new TalkDao(getActivity().getApplicationContext()).getListTalkForEventIdTAB_TALK(Long.parseLong(obj_event.id));
agrupamento(getActivity().getApplicationContext(), list_talk, false);
adapterTalk.notifyDataSetChanged();
return false;
}
});
}
示例3: configureFolderSearchView
import android.widget.SearchView; //导入方法依赖的package包/类
private void configureFolderSearchView(Menu menu) {
final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
folderMenuItem.collapseActionView();
mActionBarTitle.setText(getString(R.string.filter_folders_action));
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
mAdapter.getFilter().filter(newText);
return true;
}
});
folderSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
mActionBarTitle.setText(getString(R.string.folders_title));
return false;
}
});
}
示例4: onCreateOptionsMenu
import android.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.menu_search, menu);
final MenuItem searchItem = menu.findItem(R.id.search_view);
mSearchView = (SearchView) searchItem.getActionView();
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
mSearchView.setIconified(false);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
sharedPreferences.edit().putString(USER_QUERY, query).apply();
mSearchView.clearFocus();
finish();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return true;
}
});
mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
finish();
return false;
}
});
return true;
}
示例5: makeSearchMenuEntry
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public MenuItem makeSearchMenuEntry(Menu menu) {
MenuItem item = menu.add("Search");
searchView = new SearchView(diskusage);
origSearchBackground = searchView.getBackground();
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
item.setIcon(android.R.drawable.ic_search_category_default);
item.setActionView(searchView);
if (searchPattern != null) {
searchView.setIconified(false);
searchView.setQuery(searchPattern, false);
}
searchView.setOnCloseListener(new OnCloseListener() {
@Override
public boolean onClose() {
Log.d("diskusage", "search closed");
searchPattern = null;
diskusage.applyPatternNewRoot(masterRoot, null);
return false;
}
});
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
onQueryTextChange(query);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Log.d("diskusage", "search query changed to: " + newText);
searchPattern = newText;
applyPattern(searchPattern);
return true;
}
});
return item;
}
示例6: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
if (inflater != null && PrivacyService.checkClient()) {
// Inflate menu
inflater.inflate(R.menu.main, menu);
// Searchable
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
if (searchView != null) {
searchView.setIconifiedByDefault(false);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
searchQuery = newText;
applyFilter();
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
searchQuery = query;
applyFilter();
return true;
}
});
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
searchQuery = "";
applyFilter();
return true;
}
});
}
return true;
} else
return false;
}
示例7: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search, menu);
// Get the SearchView
MenuItem item = menu.findItem(R.id.action_search);
Assert.assertNotNull(getSupportActionBar());
final SearchView searchView = new SearchView(this);
final int textViewID = searchView.getContext().getResources()
.getIdentifier("android:id/search_src_text", null, null);
final AutoCompleteTextView searchTextView =
(AutoCompleteTextView) searchView.findViewById(textViewID);
try {
// Set the cursor to the same color as the text
Field cursorDrawable = TextView.class.getDeclaredField("mCursorDrawableRes");
cursorDrawable.setAccessible(true);
cursorDrawable.set(searchTextView, 0);
} catch (Exception e) {
Timber.e(e, "Cannot change color of cursor");
}
// Set up the query listener
MenuItemCompat.setActionView(item, searchView);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
searchString = query;
filterBySearchString();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
searchString = newText;
filterBySearchString();
return false;
}
});
//Reset the search view
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
searchString = "";
filterBySearchString();
return false;
}
});
return true;
}