Java 类android.support.v7.widget.SearchView 实例源码
项目:JKCloud
文件:OpportunityListActivity.java
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
/*简单查询*/
final MenuItem item = menu.findItem(R.id.action_search);
mSearchView = (SearchView) MenuItemCompat.getActionView(item);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
paraMap.put("keyWord", query);
showLoading();
refresh = true;
presenter.getData(1, SIZE, paraMap);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
return true;
}
项目:fuckView
文件:MainActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
final MenuItem item = menu.findItem(R.id.action_search);
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(item);
mSearchView.setIconifiedByDefault(true);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (shouldShowFAQ)
((Searchable) currentFragment).setSearchText(newText);
return true;
}
});
return super.onCreateOptionsMenu(menu);
}
项目:mvp-android-arch-component
文件:QuestionsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.questions, menu);
// Setup search widget in action bar
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setQueryHint(getString(R.string.search_hint));
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override public boolean onQueryTextSubmit(String query) {
return false;
}
@Override public boolean onQueryTextChange(String newText) {
presenter.search(newText);
return true;
}
});
return true;
}
项目:mobile-store
文件:SelectAppsView.java
@Override
public boolean buildMenu(Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.swap_next_search, menu);
MenuItem nextMenuItem = menu.findItem(R.id.action_next);
int flags = MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT;
MenuItemCompat.setShowAsAction(nextMenuItem, flags);
nextMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
getActivity().onAppsSelected();
return true;
}
});
SearchView searchView = new SearchView(getActivity());
MenuItem searchMenuItem = menu.findItem(R.id.action_search);
MenuItemCompat.setActionView(searchMenuItem, searchView);
MenuItemCompat.setShowAsAction(searchMenuItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
searchView.setOnQueryTextListener(this);
return true;
}
项目:Pickr
文件:SearchActivity.java
private void setupSearchView(Menu menu) {
ActionBar actionBar = getSupportActionBar();
Context context = actionBar != null ? actionBar.getThemedContext() : this;
SearchView searchView = new SearchView(context);
searchView.setIconifiedByDefault(false);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String queryText) {
mEasyRecycleAdapter.setItems(new ArrayList<PointOfInterest>());
if (queryText.length() > 0) {
getAutocompleteResults(queryText);
} else {
mSubscriptions.unsubscribe();
mProgressBar.setVisibility(View.GONE);
}
return false;
}
});
searchView.requestFocus();
menu.findItem(R.id.action_search).setActionView(searchView);
}
项目:furry-sniffle
文件:MainActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search_btn).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
searchView.setMaxWidth(Integer.MAX_VALUE);
searchView.requestFocus(1);
//searchView.setSubmitButtonEnabled(true);
return true;
}
项目:CodeWatch
文件:ProjectsFragment.java
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.project_menu, menu);
sortByName = menu.findItem(R.id.menu_sort_by_name);
sortByTimeSpent = menu.findItem(R.id.menu_sort_by_time);
sortByName.setChecked(isSortedByName);
sortByTimeSpent.setChecked(isSortedByName);
sortData();
final MenuItem searchItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setQueryHint(context.getString(R.string.search_hint));
searchView.setOnQueryTextListener(this);
}
项目:Open-Quran-Radio
文件:MainActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
try {
// inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main_actionbar, menu);
// Associate searchable configuration with the SearchView
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView =
(SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setSearchableInfo(
searchManager.getSearchableInfo(getComponentName()));
}catch(Exception ex){
LogHelper.e(LOG_TAG, ex.getMessage());
}finally {
return super.onCreateOptionsMenu(menu);
}
}
项目:LianXiZhihu
文件:SearchFragment.java
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_search_bookmarks, container, false);
initViews(view);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
presenter.loadResults(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
presenter.loadResults(newText);
return true;
}
});
return view;
}
项目:realm-helpers
文件:MainActivity.java
private void setupSearchView() {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
adapter.getFilter().filter(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
if(searchView.getQuery().length() == 0) {
adapter.getFilter().filter("");
}
return true;
}
});
}
项目:realm-helpers
文件:MainActivity.java
private void setupSearchView() {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
adapter.getFilter().filter(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
if(searchView.getQuery().length() == 0) {
adapter.getFilter().filter("");
}
return true;
}
});
}
项目:kolibri-android
文件:PrototypeActivity.java
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
boolean res = super.onPrepareOptionsMenu(menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
getWebViewCoordinator().onQueryByText(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
return res;
}
项目:Moodr
文件:Profile.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.filter_menu, menu); // inflate the filter
MenuItem searchViewItem = menu.findItem(R.id.filter_keyword);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchViewItem);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
filter.filter("K:" + searchView.getQuery());
searchView.clearFocus();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
filter.filter("K:" + searchView.getQuery());
return false;
}
});
return true;
}
项目:Moodr
文件:LatestActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.latest_menu, menu);
getMenuInflater().inflate(R.menu.filter_menu, menu);
MenuItem searchViewItem = menu.findItem(R.id.filter_keyword);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchViewItem);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
filter.filter("K:" + searchView.getQuery());
searchView.clearFocus();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
filter.filter("K:" + searchView.getQuery());
return false;
}
});
return true;
}
项目:youth-health
文件:MainActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.nav, menu);
SearchManager searchManager = (SearchManager)
getSystemService(Context.SEARCH_SERVICE);
searchMenuItem = menu.findItem(R.id.action_search);
searchView = (SearchView) searchMenuItem.getActionView();
searchView.setSearchableInfo(searchManager.
getSearchableInfo(getComponentName()));
searchView.setSubmitButtonEnabled(true);
return true;
}
项目:MovieGuide
文件:SearchActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
placeholderImage = ContextCompat.getDrawable(getApplicationContext(), R.drawable.disk_reel);
RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.search_recycler_view);
mSearchView = (SearchView) findViewById(R.id.search_view);
setupActionBar();
setupSearchView();
List<MultiSearch.MultiSearchItem> searchItems = new ArrayList<>();
mAdapter = new SearchAdapter(searchItems);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setAdapter(mAdapter);
// Obtain the FirebaseAnalytics instance.
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
ActivityUtils.firebaseAnalyticsLogEventSelectContent(mFirebaseAnalytics, PAGE_SEARCH, PAGE_SEARCH, TYPE_PAGE);
}
项目:InifiniteRecyclerView
文件:MainActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the options menu from XML
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
SearchManager searchManager = (SearchManager)
getSystemService(Context.SEARCH_SERVICE);
MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setSearchableInfo(searchManager.
getSearchableInfo(getComponentName()));
searchView.setOnQueryTextListener(this);
MenuItemCompat.setOnActionExpandListener(searchMenuItem, this);
return true;
}
项目:JKCloud
文件:CheckActivity.java
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
/*简单查询*/
final MenuItem item = menu.findItem(R.id.action_search);
mSearchView = (SearchView) MenuItemCompat.getActionView(item);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
pareMap.put("keyWord", query);
showLoading();
refresh = true;
presenter.getData(1, SIZE, pareMap);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
return true;
}
项目:recycler-view-search
文件:MainActivity.java
private void search(SearchView searchView) {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (mAdapter != null) mAdapter.getFilter().filter(newText);
return true;
}
});
}
项目:RxRedux
文件:UserListActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.list_menu, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setOnCloseListener(() -> {
postOnResumeEvents.onNext(new GetPaginatedUsersEvent(viewState == null ? -1 : viewState.getLastId()));
return false;
});
eventObservable = eventObservable.mergeWith(RxSearchView.queryTextChanges(searchView)
.filter(charSequence -> !charSequence.toString().isEmpty())
.map(query -> new SearchUsersEvent(query.toString()))
.throttleLast(100, TimeUnit.MILLISECONDS)
.debounce(200, TimeUnit.MILLISECONDS)
.doOnEach(searchUsersEvent -> Log.d("SearchEvent", FIRED)));
return super.onCreateOptionsMenu(menu);
}
项目:Todule-android
文件:ToduleListFragment.java
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if(loaderId == DELETED_LOADER_ID){
inflater.inflate(R.menu.menu_fragment_bin, menu);
}
// Place an action bar item for searching.
MenuItem item = menu.add("Search");
item.setIcon(R.drawable.ic_search_white_24dp);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM|MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
searchView = new SearchView(myActivity);
searchView.setMaxWidth(Integer.MAX_VALUE);
// Set searchbox text to white
EditText searchEditText = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
searchEditText.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
searchEditText.setHintTextColor(ContextCompat.getColor(getContext(), R.color.white));
searchView.setOnQueryTextListener(this);
item.setActionView(searchView);
super.onCreateOptionsMenu(menu, inflater);
}
项目:FloatingNew
文件:MainActivity.java
private void search(SearchView searchView, final Menu menu) {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
mAdapter.getFilter().filter(newText);
return true;
}
});
}
项目:MovingGdufe-Android
文件:SearchBookActivity.java
@Override
protected void loadData() {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (TextUtils.getTrimmedLength(query) == 0) return false;
searchView.setIconified(true); //清空文本,防止操作一次却调用两次onQueryTextSubmit
curSearchWord = query;
curSearchPage = 1;
realQueryBook(query,curSearchPage);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
}
项目:PSNine
文件:MainActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Bundle bundle = new Bundle();
bundle.putInt("type", getCurrentType());
bundle.putString("query", query);
ActivityUtils.startActivity(bundle, TopicsActivity.class);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
return super.onCreateOptionsMenu(menu);
}
项目:tumbviewer
文件:SearchFragment.java
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_search, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.blog_list);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
SearchView searchView = (SearchView) view.findViewById(R.id.searchView);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
openBlogPosts(query);
// openTaggedPosts(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
loaded = false;
referSize = 0;
return view;
}
项目:AndroidSnooper
文件:HttpCallSearchActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_http_call_search);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
((SearchView)toolbar.findViewById(R.id.searchView)).setOnQueryTextListener(this);
loaderView = findViewById(R.id.embedded_loader);
recyclerView = (RecyclerView) findViewById(R.id.list);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
DividerItemDecoration itemDecoration = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL, R.drawable.grey_divider);
recyclerView.addItemDecoration(itemDecoration);
recyclerView.setItemAnimator(new DefaultItemAnimator());
httpCallListAdapter = new HttpCallListAdapter(new ArrayList<HttpCallRecord>(), this);
recyclerView.setAdapter(httpCallListAdapter);
httpClassSearchPresenter = new HttpClassSearchPresenter(new SnooperRepo(this), this, new BackgroundTaskExecutor(this));
}
项目:MusicX-music-player
文件:ArtistListFragment.java
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.artist_view_menu, menu);
searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.artist_search));
searchView.setOnQueryTextListener(this);
searchView.setQueryHint("Search artist");
if (Extras.getInstance().artistView()) {
menu.findItem(R.id.grid_view).setVisible(false);
} else {
menu.findItem(R.id.grid_view).setVisible(true);
}
}
项目:GitHub
文件:SelectCityActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_search) {
SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
RxSearchView.queryTextChanges(searchView)
.map(charSequence -> charSequence == null ? null : charSequence.toString().trim())
.throttleLast(100, TimeUnit.MILLISECONDS)
.debounce(100, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(searchText -> selectCityFragment.cityListAdapter.getFilter().filter(searchText));
return true;
}
return super.onOptionsItemSelected(item);
}
项目:GitHub
文件:ReadCHMActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_chm_reader, menu);
MenuItem searchMenuItem = menu.findItem(R.id.menu_search);//在菜单中找到对应控件的item
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
mWebView.clearMatches();
return false;
}
});
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
mWebView.findAllAsync(newText);
try {
for (Method m : WebView.class.getDeclaredMethods()) {
if (m.getName().equals("setFindIsUp")) {
m.setAccessible(true);
m.invoke(mWebView, true);
break;
}
}
} catch (Exception ignored) {
}
return false;
}
});
return true;
}
项目:GitHub
文件:SearchViewActivity.java
@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);
}
项目:Tusky
文件:SearchActivity.java
private void setupSearchView(SearchView searchView) {
searchView.setIconifiedByDefault(false);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
searchView.setSearchableInfo(searchableInfo);
}
searchView.setOnQueryTextListener(this);
searchView.requestFocus();
searchView.setMaxWidth(Integer.MAX_VALUE);
}
项目:QuranAndroid
文件:HomeActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_activity_home, menu);
//init search in the toolbar
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
//listener for click in search button
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
startActivity(new Intent(HomeActivity.this, SearchActivity.class)
.putExtra(AppConstants.General.SEARCH_TEXT, query));
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
return true;
}
项目:QuranAndroid
文件:HomeActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_activity_home, menu);
//init search in the toolbar
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
//listener for click in search button
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
startActivity(new Intent(HomeActivity.this, SearchActivity.class)
.putExtra(AppConstants.General.SEARCH_TEXT, query));
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
return true;
}
项目:Tusky
文件:SearchActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.search_toolbar, menu);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search)
.getActionView();
setupSearchView(searchView);
if (currentQuery != null) {
searchView.setQuery(currentQuery, false);
}
return true;
}
项目:mobile-store
文件:SwapAppsView.java
@Override
public boolean buildMenu(Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.swap_search, menu);
SearchView searchView = new SearchView(getActivity());
MenuItem searchMenuItem = menu.findItem(R.id.action_search);
MenuItemCompat.setActionView(searchMenuItem, searchView);
MenuItemCompat.setShowAsAction(searchMenuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
searchView.setOnQueryTextListener(this);
return true;
}
项目:ReadMark
文件:SearchActivity.java
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;
}
项目:SOS-The-Healthcare-Companion
文件:BaseFragment.java
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
MenuItem item = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
searchView.setOnQueryTextListener(this);
}
项目:chuck
文件:TransactionListFragment.java
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.chuck_main, menu);
MenuItem searchMenuItem = menu.findItem(R.id.search);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setOnQueryTextListener(this);
searchView.setIconifiedByDefault(true);
super.onCreateOptionsMenu(menu, inflater);
}
项目:DuckDuckDefine-Android
文件:SearchActivity.java
private void init() {
initialiseToolbar();
recyclerView.setHasFixedSize(true);
recyclerView.setAdapter(recyclerAdapter);
if (recyclerView.getLayoutManager() == null) {
linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(linearLayoutManager);
}
swipeRefreshLayout.setColorSchemeColors(ViewUtil.colorPaletteSwipeRefresh());
searchView.setIconified(false);
searchView.setIconifiedByDefault(false);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
performSearchForTerm(query); // Search query when enter pressed
searchView.clearFocus();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
searchPresenter.loadLastSearchTerm();
}
项目:Treebolic
文件:MainActivity.java
@Override
public boolean onCreateOptionsMenu(@NonNull final Menu menu)
{
// inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
// search view
final MenuItem searchMenuItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener()
{
@Override
public boolean onQueryTextSubmit(final String query)
{
searchView.clearFocus();
searchView.setQuery("", false);
tryStartTreebolic(query);
return true;
}
@Override
public boolean onQueryTextChange(final String newText)
{
return false;
}
});
return true;
}