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:org.muckebox.android.ui.activity.WizardActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();

    inflater.inflate(R.menu.wizard, menu);

    mDoneItem = menu.findItem(R.id.wizard_action_done);
    mTestItem = menu.findItem(R.id.wizard_action_test);

    mDoneItem.setVisible(false);//from  ww  w . ja va  2 s.c o  m

    return super.onCreateOptionsMenu(menu);
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.list.ActivityList.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    // hide manual sort for all item
    menu.findItem(R.id.menu_sort_manual).setVisible(mCurrentList > 0).setEnabled(mCurrentList > 0);
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.adithya321.sharesanalysis.fragments.ShareHoldingsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.share_sales, menu);
    actionProgressItem = menu.findItem(R.id.action_progress);
    actionRefreshItem = menu.findItem(R.id.action_refresh);
    actionProgressItem.setVisible(true);
    actionRefreshItem.setVisible(false);

    ProgressBar progressBar = (ProgressBar) actionProgressItem.getActionView()
            .findViewById(R.id.pbProgressAction);
    progressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(android.R.color.white),
            android.graphics.PorterDuff.Mode.SRC_IN);

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:ca.rmen.android.palidamuerte.app.poem.detail.PoemDetailFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    Log.v(TAG, "onPrepareOptionsMenu");
    super.onPrepareOptionsMenu(menu);
    MenuItem fav = menu.findItem(R.id.action_favorite);
    if (fav == null) {
        Log.v(TAG, "Menu not inflated yet?");
        return;//from   w  w  w  .  j  a v a 2  s  .c  om
    }
    if (mIsFavorite) {
        fav.setTitle(R.string.action_favorite_activated);
        fav.setIcon(R.drawable.ic_action_favorite_activated);
    } else {
        fav.setTitle(R.string.action_favorite_normal);
        fav.setIcon(R.drawable.ic_action_favorite_normal);
    }
}

From source file:com.abid_mujtaba.fetchheaders.AccountsActivity.java

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

    MenuItem item = menu.findItem(R.id.menu_add_account); // We gain access to the menu item and through it to its action view (the actionLayout definied in the menu layout)
    View itemView = MenuItemCompat.getActionView(item);

    if (itemView != null) {
        itemView.setOnClickListener(new View.OnClickListener() { // To make the menu item work when it has an actionView we must explicitly attach a clicklistener to the actionview otherwise nothing happens when the menu is pressed
            @Override // Note: With this implementation we do NOT need an onOptionItemSelected method
            public void onClick(View view) {
                startActivity(new Intent("com.abid_mujtaba.fetchheaders.AccountSettingActivity"));
            }// www .  j ava  2 s .c  o m
        });
    }

    return true;
}

From source file:com.support.android.designlibdemo.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    switch (AppCompatDelegate.getDefaultNightMode()) {
    case AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM:
        menu.findItem(R.id.menu_night_mode_system).setChecked(true);
        break;/*from   ww w . j  a v a  2s  .c o  m*/
    case AppCompatDelegate.MODE_NIGHT_AUTO:
        menu.findItem(R.id.menu_night_mode_auto).setChecked(true);
        break;
    case AppCompatDelegate.MODE_NIGHT_YES:
        menu.findItem(R.id.menu_night_mode_night).setChecked(true);
        break;
    case AppCompatDelegate.MODE_NIGHT_NO:
        menu.findItem(R.id.menu_night_mode_day).setChecked(true);
        break;
    }
    return true;
}

From source file:com.vmihalachi.turboeditor.activity.SelectFileActivity.java

/**
 * {@inheritDoc}//from   w w w.j  a v a  2  s.com
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_select_file, menu);
    menu.findItem(R.id.im_button)
            .setTitle(getString(wantAFolder ? R.string.seleziona : android.R.string.cancel));
    return super.onCreateOptionsMenu(menu);
}

From source file:br.com.moviecreator.views.home.HomeFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.home, menu);

    initSearch(menu.findItem(R.id.action_search));
}

From source file:com.afollestad.overhear.ui.OverviewScreen.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.overview_screen, menu);
    menu.findItem(R.id.createPlaylist).setVisible(mViewPager.getCurrentItem() == 0);
    menu.findItem(R.id.clearRecents).setVisible(mViewPager.getCurrentItem() == 1);
    return true;/*from   w  ww.  j ava 2s  .  co m*/
}

From source file:bala.padio.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.menu_main, menu);
    playerControlMenu = menu.findItem(R.id.action_player);

    // update player icon
    updtePlayerIcon(Player.isPlaying());

    return true;/*w w w .java  2 s  .c o  m*/
}