Example usage for android.view Menu findItem

List of usage examples for android.view Menu findItem

Introduction

In this page you can find the example usage for android.view Menu findItem.

Prototype

public MenuItem findItem(int id);

Source Link

Document

Return the menu item with a particular identifier.

Usage

From source file:com.github.chenxiaolong.dualbootpatcher.MainActivity.java

public void showExit(boolean visible) {
    Menu menu = mDrawerView.getMenu();
    MenuItem item = menu.findItem(R.id.nav_exit);
    if (item != null) {
        item.setVisible(visible);//from  w  w  w. j a  v  a  2 s.c  om
    }
}

From source file:com.sakisds.icymonitor.fragments.graph.GraphContainerFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_graphs, menu);
    mKeepOnItem = menu.findItem(R.id.item_keep_screen_on);
    mPauseItem = menu.findItem(R.id.item_resume_pause);
    refreshSettings();/*from  w  w w . j a v  a2 s.c om*/
}

From source file:com.maskyn.fileeditorpro.activity.SelectFileActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_select_file, menu);
    mSearchViewMenuItem = menu.findItem(R.id.im_search);
    mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchViewMenuItem);
    mSearchView.setIconifiedByDefault(true);
    mSearchView.setOnQueryTextListener(this);
    mSearchView.setSubmitButtonEnabled(false);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.andrew67.ddrfinder.activity.MapViewer.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    reloadButton = menu.findItem(R.id.action_reload);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.airk.interpolatordiagram.app.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.clear();/*from  ww w . j a  v a2 s  .  c  o  m*/
    if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mList)) {
        return true;
    }
    getMenuInflater().inflate(R.menu.main, menu);
    if (mSelectedInterpolator != -1) {
        menu.findItem(R.id.action_play).setVisible(true);
        View v = MenuItemCompat.getActionView(menu.findItem(R.id.action_play));
        v.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                final ObjectAnimator animator = ObjectAnimator.ofFloat(v, "rotationX", 0, 360);
                animator.setDuration(800).setRepeatCount(ObjectAnimator.INFINITE);
                animator.setInterpolator(new LinearInterpolator());
                animator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationStart(Animator animation) {
                        super.onAnimationStart(animation);
                        v.setClickable(false);
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        v.setClickable(true);
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {
                        super.onAnimationCancel(animation);
                        ObjectAnimator a = ObjectAnimator.ofFloat(v, "rotationX", 0);
                        a.setDuration(1).start();
                        v.setClickable(true);
                    }
                });
                animator.start();
                Fragment fragment = FragmentFactory.getInstance().getInterpolator(mSelectedInterpolator);
                ((BaseFragment) fragment).getDiagramView().playBalls(new DiagramView.AnimationListener() {
                    @Override
                    public void onAnimateFinished() {
                        animator.cancel();
                    }
                });
            }
        });
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.anadoluuniversity.tinyreader.OcrCaptureActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    if (getSupportFragmentManager().findFragmentByTag("FragmentCamera") != null
            && getSupportFragmentManager().findFragmentByTag("FragmentCamera").isVisible()) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_search, menu);
        MenuItem item = menu.findItem(R.id.menuSearch);

        SearchView searchView = (SearchView) item.getActionView();

        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override/*from w  ww  .j a  v  a2  s .c  o  m*/
            public boolean onQueryTextSubmit(String query) {
                Log.d("searchbar_submit", query);
                wordToSearch = query;
                return false;
            }

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

    return super.onCreateOptionsMenu(menu);
}

From source file:com.abhijitvalluri.android.fitnotifications.AppChoicesActivity.java

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

    MenuItem searchItem = menu.findItem(R.id.menu_app_search);
    MenuItem filterEnabledAppsItem = menu.findItem(R.id.menu_filter_enabled);

    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(getString(R.string.search_query_hint));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override/*from  w w w  .  ja  v  a2 s.co  m*/
        public boolean onQueryTextSubmit(String query) {
            return recyclerViewShowSearchResult(query);
        }

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

    searchItem.setEnabled(false);
    filterEnabledAppsItem.setEnabled(false);
    filterEnabledAppsItem.setChecked(mShowOnlyEnabledApps);

    return true;
}

From source file:ca.ualberta.cs.drivr.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item = menu.findItem(R.id.action_settings);
    item.setVisible(false);/*from   w ww. ja v  a  2  s. c  o  m*/
    super.onPrepareOptionsMenu(menu);
    return true;
}

From source file:com.golfwallet.main.MainActivity.java

/**   
 *  \brief//w  w w  .ja va  2  s .co m
 *    Method which create the option menu of the top right of the app.
 *    \param menu Menu that contains the different items to be displayed
 *  \return True if the menu is correctly created
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);

    if (ReadWriteData.getConnectionState(context)) {
        menu.findItem(R.id.action_logout).setTitle("Logout");
    } else {
        menu.findItem(R.id.action_logout).setTitle("Login");
    }
    return true;
}

From source file:ca.rmen.android.poetassistant.main.reader.ReaderFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    boolean hasEnteredText = !TextUtils.isEmpty(mBinding.tvText.getText());
    MenuItem menuItem = menu.findItem(R.id.action_new);
    if (menuItem == null) {
        Log.d(TAG, "Unexpected: new menu item missing from reader fragment. Monkey?");
    } else {/* ww  w  .  j av  a2  s .c o  m*/
        menuItem.setEnabled(hasEnteredText);
    }

    menuItem = menu.findItem(R.id.action_save);
    if (menuItem == null) {
        Log.d(TAG, "Unexpected: save menu item missing from reader fragment. Monkey?");
    } else {
        menuItem.setEnabled(mPoemPrefs.hasSavedPoem());
    }

    menuItem = menu.findItem(R.id.action_save_as);
    if (menuItem == null) {
        Log.d(TAG, "Unexpected: save as menu item missing from reader fragment. Monkey?");
    } else {
        menuItem.setEnabled(hasEnteredText);
    }
}