Example usage for android.view MenuItem getActionView

List of usage examples for android.view MenuItem getActionView

Introduction

In this page you can find the example usage for android.view MenuItem getActionView.

Prototype

public View getActionView();

Source Link

Document

Returns the currently set action view for this menu item.

Usage

From source file:com.readystatesoftware.chuck.internal.ui.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);
}

From source file:br.liveo.ndrawer.FragmentMain.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // TODO Auto-generated method stub
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu, menu);

    //Select search item
    final MenuItem menuItem = menu.findItem(R.id.menu_search);
    menuItem.setVisible(true);//from  w  w  w .  ja v a2s .  com

    SearchView searchView = (SearchView) menuItem.getActionView();
    searchView.setQueryHint(this.getString(R.string.search));

    ((EditText) searchView.findViewById(R.id.search_src_text))
            .setHintTextColor(getResources().getColor(R.color.nliveo_white));
    searchView.setOnQueryTextListener(onQuerySearchView);

    menu.findItem(R.id.menu_add).setVisible(true);

    mSearchCheck = false;
}

From source file:com.jackie.searchFunction.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.options_menu, menu);

    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    MenuItem menuItem = menu.findItem(R.id.action_search);
    if (SDKUtils.IS_HONEYCOMB) {
        android.widget.SearchView searchView = (android.widget.SearchView) menuItem.getActionView();
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    } else {//w  w w  . j a va  2s.  c om
        SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    }

    return true;
}

From source file:at.wada811.android.library.demos.loader.LoaderListActivity.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void initSearchView(final MenuItem menuItem) {
    if (AndroidUtils.isMoreThanBuildVersion(Build.VERSION_CODES.ICE_CREAM_SANDWICH)) {
        final SearchView searchView = (SearchView) menuItem.getActionView();
        searchView.setOnQueryTextListener(new OnQueryTextListener() {
            @Override//from ww w .j ava 2  s. c o  m
            public boolean onQueryTextSubmit(String query) {
                mLoaderListFragment.init();
                mLoaderListFragment.searchImageWithKeyword(query);
                menuItem.collapseActionView();
                getActionBar().setTitle(query);
                return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                return false;
            }
        });
        searchView.setOnQueryTextFocusChangeListener(new OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (!hasFocus) {
                    menuItem.collapseActionView();
                }
            }
        });
    }
}

From source file:com.meycup.ducksound.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    SearchView searchView;//  w ww  .j a v  a 2s.  com

    MenuItem menuItem = menu.findItem(R.id.search);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        searchView = (SearchView) menuItem.getActionView();
    } else {
        searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
    }

    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setQueryHint("Pesquise por sua msica");
    return true;
}

From source file:org.openmrs.mobile.activities.activevisits.ActiveVisitsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.find_visits_menu, menu);
    final SearchView findVisitView;
    MenuItem mFindVisitItem = menu.findItem(R.id.actionSearchLocalVisits);
    if (OpenMRS.getInstance().isRunningHoneycombVersionOrHigher()) {
        findVisitView = (SearchView) mFindVisitItem.getActionView();
    } else {//w w  w. j av a 2s  .  c  o m
        findVisitView = (SearchView) MenuItemCompat.getActionView(mFindVisitItem);
    }

    findVisitView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            findVisitView.clearFocus();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            if (!query.isEmpty()) {
                mPresenter.updateVisitsInDatabaseList(query);
            } else {
                mPresenter.updateVisitsInDatabaseList();
            }
            return true;
        }
    });
    return true;
}

From source file:ilovezappos.zappos.kpk.ilovezappos.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);

    menucartItem = menu.findItem(R.id.shopping_cart);
    MenuItem item = menu.findItem(R.id.search_bar);

    SearchView searchView = (SearchView) item.getActionView();
    searchView.setQueryHint("Search Product");
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override//from w  ww .j  a va2  s .c  o m
        public boolean onQueryTextSubmit(String query) {
            fetchProducts(query);

            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });

    return super.onCreateOptionsMenu(menu);
}

From source file:org.openmrs.mobile.activities.formentrypatientlist.FormEntryPatientListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.form_entry_patient_list_menu, menu);
    final SearchView findPatientView;
    MenuItem mFindPatientMenuItem = menu.findItem(R.id.actionSearchRemoteFormEntry);
    if (OpenMRS.getInstance().isRunningHoneycombVersionOrHigher()) {
        findPatientView = (SearchView) mFindPatientMenuItem.getActionView();
    } else {//from  www. j  a v  a  2  s  .  c o m
        findPatientView = (SearchView) MenuItemCompat.getActionView(mFindPatientMenuItem);
    }

    // Search function
    findPatientView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            findPatientView.clearFocus();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            mPresenter.setQuery(query);
            mPresenter.updatePatientsList();
            return true;
        }
    });
    return true;
}

From source file:org.openmrs.mobile.activities.syncedpatients.SyncedPatientsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.find_locally_and_add_patients_menu, menu);

    // Search function
    MenuItem searchMenuItem = menu.findItem(R.id.actionSearchLocal);
    if (OpenMRS.getInstance().isRunningHoneycombVersionOrHigher()) {
        searchView = (SearchView) searchMenuItem.getActionView();
    } else {//from   w w  w  . ja  va2s .c  o m
        searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
    }
    if (StringUtils.notEmpty(query)) {
        searchMenuItem.expandActionView();
        searchView.setQuery(query, true);
        searchView.clearFocus();
    }
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            searchView.clearFocus();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            mPresenter.setQuery(query);
            mPresenter.updateLocalPatientsList();
            return true;
        }
    });

    return true;
}

From source file:com.openarc.nirmal.mytrack.CIRContactActivity.java

private void setupSearchMenu(MenuItem searchItem) {
    showWaiting(CIRContactActivity.this);
    searchView = (SearchView) searchItem.getActionView();
    new CIRContactTask().execute();
    searchView.setOnQueryTextListener(this);
}