use of android.widget.SearchView in project weiciyuan by qii.
the class SearchMainActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.actionbar_menu_searchmainactivity, menu);
final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
searchView.setIconifiedByDefault(false);
searchView.setSubmitButtonEnabled(false);
searchView.requestFocus();
return super.onCreateOptionsMenu(menu);
}
use of android.widget.SearchView in project coursera-android by aporter.
the class DialtactsActivity method prepareSearchView.
private void prepareSearchView() {
final View searchViewLayout = getLayoutInflater().inflate(R.layout.dialtacts_custom_action_bar, null);
mSearchView = (SearchView) searchViewLayout.findViewById(R.id.search_view);
mSearchView.setOnQueryTextListener(mPhoneSearchQueryTextListener);
mSearchView.setOnCloseListener(mPhoneSearchCloseListener);
// Since we're using a custom layout for showing SearchView instead of letting the
// search menu icon do that job, we need to manually configure the View so it looks
// "shown via search menu".
// - it should be iconified by default
// - it should not be iconified at this time
// See also comments for onActionViewExpanded()/onActionViewCollapsed()
mSearchView.setIconifiedByDefault(true);
mSearchView.setQueryHint(getString(R.string.hint_findContacts));
mSearchView.setIconified(false);
mSearchView.setOnQueryTextFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (hasFocus) {
showInputMethod(view.findFocus());
}
}
});
if (!ViewConfiguration.get(this).hasPermanentMenuKey()) {
// Filter option menu should be shown on the right side of SearchView.
final View filterOptionView = searchViewLayout.findViewById(R.id.search_option);
filterOptionView.setVisibility(View.VISIBLE);
filterOptionView.setOnClickListener(mFilterOptionClickListener);
}
getActionBar().setCustomView(searchViewLayout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}
use of android.widget.SearchView in project XPrivacy by M66B.
the class ActivityMain method onCreateOptionsMenu.
// Options
@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;
}
use of android.widget.SearchView in project xabber-android by redsolution.
the class BottomMenu method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.view_bottom_navigation, container, false);
view.findViewById(R.id.btnRecent).setOnClickListener(this);
view.findViewById(R.id.btnMenu).setOnClickListener(this);
btnSearch = (ImageView) view.findViewById(R.id.btnSearch);
btnSearch.setOnClickListener(this);
searchLayout = (RelativeLayout) view.findViewById(R.id.searchLayout);
searchLayout.setOnClickListener(this);
controlView = (LinearLayout) view.findViewById(R.id.controlView);
expandSearchLayout = (RelativeLayout) view.findViewById(R.id.expandSearchLayout);
accountList = (RecyclerView) view.findViewById(R.id.accountList);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
accountList.setLayoutManager(layoutManager);
adapter = new AccountShortcutAdapter(items, getActivity(), this);
accountList.setAdapter(adapter);
searchView = (SearchView) view.findViewById(R.id.searchView);
searchView.setQueryHint(getString(R.string.contact_search_hint));
searchView.setOnQueryTextListener(new android.widget.SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
listener.onSearch(newText);
return true;
}
});
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
closeSearch();
return true;
}
});
tvUnreadCount = (TextView) view.findViewById(R.id.tvUnreadCount);
return view;
}
use of android.widget.SearchView in project Android-Developers-Samples by johnjohndoe.
the class MainActivity method onCreateOptionsMenu.
@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);
// Associate searchable configuration with the SearchView
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
return true;
}
Aggregations