Search in sources :

Example 26 with SearchView

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);
}
Also used : SearchView(android.widget.SearchView) SearchManager(android.app.SearchManager)

Example 27 with SearchView

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));
}
Also used : OnFocusChangeListener(android.view.View.OnFocusChangeListener) LayoutParams(android.app.ActionBar.LayoutParams) View(android.view.View) ContactListItemView(com.android.contacts.list.ContactListItemView) SearchView(android.widget.SearchView)

Example 28 with SearchView

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;
}
Also used : SearchView(android.widget.SearchView) MenuInflater(android.view.MenuInflater)

Example 29 with SearchView

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;
}
Also used : SearchView(android.widget.SearchView) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) SearchView(android.widget.SearchView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Nullable(androidx.annotation.Nullable)

Example 30 with SearchView

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;
}
Also used : SearchView(android.widget.SearchView) SearchManager(android.app.SearchManager)

Aggregations

SearchView (android.widget.SearchView)67 View (android.view.View)35 TextView (android.widget.TextView)30 MenuItem (android.view.MenuItem)26 ImageView (android.widget.ImageView)16 ListView (android.widget.ListView)15 AdapterView (android.widget.AdapterView)14 RecyclerView (android.support.v7.widget.RecyclerView)13 SearchManager (android.app.SearchManager)11 Activity (android.app.Activity)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 SettingsActivity (com.android.settings.SettingsActivity)7 ViewGroup (android.view.ViewGroup)6 Toolbar (android.widget.Toolbar)6 Intent (android.content.Intent)4 MenuInflater (android.view.MenuInflater)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 Nullable (android.support.annotation.Nullable)3 FragmentActivity (android.support.v4.app.FragmentActivity)3 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)3